Physical, emotional, and spiritual sickness can debilitate a person for one of three reasons:
1. General sin of mankind in the world…a general depravity and decay that afflicts the whole world due to the rebellion of mankind in general against God.
2. Personal, individual sin…sickness and even death comes upon individuals due to their own direct offense to God’s character and nature. Ex: Acts 5; 1 Corinthians 11
3. Demonic sin…satan and demons afflict people with various kinds of illness as God permits for His purpose. Ex. Job
It is for reason #2 that James pairs confession of sin in context with praying for healing by the anointing of the Holy Spirit.
James 5:13-16 ESV
Is anyone among you suffering? Let him pray. Is anyone cheerful? Let him sing praise.  Is anyone among you sick? Let him call for the elders of the church, and let them pray over him, anointing him with oil in the name of the Lord.  And the prayer of faith will save the one who is sick, and the Lord will raise him up. And if he has committed sins, he will be forgiven.  Therefore, confess your sins to one another and pray for one another, that you may be healed. The prayer of a righteous person has great power as it is working.
Spiritual healing in your inner health before God is a catalyst God uses to result in physical, external healing.
Healing may come in one of three ways:
1. Immediate healing through the miracle-working Holy Spirit.
2. Gradual healing through medicine.
3. Eventual complete healing in the resurrected, glorified body.