Our view of prayer is much like a view of God that we roundly criticize, namely, that it is man-centered. We view ourselves, the world, the universe and God himself from our own chair. While it is impossible for us to not see things from this vantage (it is where we are), God invites us through prayer (by way of his Son and by the power of his Spirit) to see things from his perspective. (With God, all things are possible.)
When we encounter adversity, from our chair we see the need for that adversity to be dealt away, as if it were our enemy. From God’s perspective, this adversity may be the means by which he gives us a clearer view of his glory.
When James says that we should count it all joy when we meet trials of various kinds (adversity, pain, suffering, illness, persecution, famine, poverty, weakness, sorrow, grief) he means for us to actually see it as an occasion for joy. This is because that testing of our faith produces something in us…steadfastness. He also encourages us (under the inspiration of the Holy Spirit) to let steadfastness have its full effect, that we may be perfect and complete, lacking in nothing.
The question then is, why would we choose to pray that away?! Because it makes us uncomfortable? (See Romans 5:3ff.) If we lack the wisdom to understand this, that is what we should ask God for…and he will give it to us generously (maybe by sending trial!).
Suffering is painful…that is why it is called suffering. But God works through our suffering for his glory and for our good. Are we so quick to settle for ease and comfort when we could have God?