Why confess misdeeds to one another? Is it not enough that God knows about them? It is understandable when the matter concerns a wrong committed precisely against that person: then this wrong lies between us as a barrier to pure relationships; the relationship is darkened by the concealment of this wrong and by its possible painful consequences. Confession opens the road to forgiveness, by which every barrier is destroyed. This is understandable. But why confess wrongs that do not concern that person? Perhaps because in the Church we are all members of one another, and sin in one of us touches the whole body. And again, confession leads to forgiveness and to healing from the spiritual sickness of sin both for the sinner himself and for the whole body. In addition, wrongs arise from spiritual problems, and knowing them allows other people to pray "with aim" for these problems, that is, for healing.
And it is also worth saying that the expression used here by the apostle James should not mislead us: it is not prayer that heals, and prayer is not what "can do much". God can do much and heals, while prayer is our testimony that we are ready to receive His grace, His healing.