This question should always be approached with humility and care. Though theological ideas can be shared, it’s important to remember that this is often asked with names and faces in the mind of the asker. The short answer is, humanity cannot fully articulate why not every person prayed over is healed.
That said, there are some helpful answers that can be found. Jesus was clearly in support of healing—He spent more time doing that than preaching, and even sent out His disciples to do the same (Matt. 10:1). So why not everyone?
First, not everyone wants to be healed. Whether it’s because the pain has become too familiar to part with, or it provides some other pseudo-comfort, some people simply don’t want the change. Jesus even asked a man if he wanted to be made well before healing him (John 5:6).
Second, not every prayer for healing is in faith. Jesus repeatedly praised the faith of those that He healed (Mark 5:34; 10:52; Luke 7:50). When His disciples were unable to cast a demon out of a child, Jesus told them it was due to their lack of faith (Matt. 17:19–21).
Third, humanity occupies a world of sin. This sin has infected our genetic makeup, habits, choices, environments, and lives. It is painful evidence of a great controversy raging in this world between good and evil. Jesus did not come and heal to make a utopia on earth where all were made well. He always pointed to the kingdom to come, even to those He healed. Disease—physical, mental, and spiritual—is a result of sin.
Fourth, it’s not always what’s best. Ellen White shared how her own life was plagued by disease, and how God allowed it as a means of keeping her close to Him. (Ellen G. White, Early Writings, 21.) Sometimes the disease comes as a result of harmful habits and choices, and God is choosing not to interfere with natural consequences, lest that person be encouraged in such a harmful direction. (Ellen G. White, Counsels on Health, 373, 374.) Other times, sickness draws the individual closer to God and healing would only harm their connection with Him: “He who is acquainted with the hearts of all men knows whether the person, if raised up, would glorify His name or dishonor Him by backsliding and apostasy. . . . If the Lord sees it will best honor Him, He will answer our prayers.” (Ellen G. White, Testimonies for the Church, vol. 2, 147, 148.) In the light of eternity, is not eternal life more precious than a few years on earth? It is only with deep trust in God and an eternal perspective that this is seen as merciful as it is.
There can be other reasons too. God knows. God still desires to heal His people, and He does in countless ways still today. Like Jesus in Gethsemane, we may pray for deliverance, and in the same breath, ask for it according to His will.