What Does Prayer Do?
There are actually several levels on which we should think about prayer as "working." First, prayer always works on us. It changes our hearts and our perspectives.
Before it is a discrete set of requests and thanksgivings, prayer is a meeting with God. We often lost sight of this profound reality - that in prayer we are actually drawing near to God Himself. It is a relational activity, and like any relational encounter, it shapes and changes us.
This can manifest in lots of ways. One is that prayer shifts our priorities. When we start praying for help for someone we are often spurred on to be that help. When we pray for a friend to know Jesus it motivates us to share Jesus with them. In addition, prayer comforts our hearts. Even if we are praying for a situation beyond our control, simply entering into God's presence can bring a peace and reminder that He is there and He is in control. When Peter reminds us to "cast all your anxiety on Him because He cares for you," (1 Peter 5:7) it is not simply that he will solve the things we are anxious about. It is even more that simply being in the presence of our caring Creator transforms our experience of fear.
We need to start here because this is always true. Below we'll talk about what else prayer does (and doesn't) do, but even if it doesn't seem to be accomplishing anything outside of us, meeting with our Father does something inside us that is powerful and necessary.
That said, prayer's power for self-transformation is not the full answer. Saying only that can cheapen the idea. It reduces it to simply some meditative spiritual exercise, a sort of God-tinged mindfulness activity. When James says, "The prayer of a righteous person has great power as it is working," he certainly doesn't seem to just imagine some internal power of positivity. (James 5:16) So we must join that reality with two other considerations.
On the one hand, prayer never "works" on God - which is to say, it doesn't give us the power to make God change His mind. While there is a "but" coming below, we need to be clear on this point. Sometimes what people imagine happening in prayer is that they might somehow alter God Himself. That by force of words or faithfulness His eternal decrees will be changed.
It is true that there are places where God is pictured as "changing." For instance, Moses intercedes on behalf of Israel after the nation fell into idolatry and the text tells us, "and the Lord relented from the disaster that he had spoken of bringing on his people." (Exodus 32:14) That said, Scripture is also full of direct statements about the reality that God does not change. (Numbers 23:19, Malachi 3:6, James 1:17, etc.) Given these declarations, theologians have long held that those passages where God relents are not describing a change in his internal being but rather a change in His actions in the world - more on that in a minute.
There are moments when we don't like this reality. We as creatures have vested interests in the world, and we often wish we could force God to honor those interests. Yet there are any number of reasons this would be a problem. We are much less wise than God. Our knowledge has limits. Our hearts are selfish. C.S. Lewis, recognizing his often foolish requests in prayer, remarked that "I must often be glad that certain past prayers of my own were not granted." If we were to have the power to change God through prayer, it would certainly be for the worse. It would make Him more like us, robbing Him of His perfection.
However, while this is true, the other side is that God often works through prayer. It does not change God, but God uses our prayers to change the world.
James tells us that "the prayer of a righteous person has great power as it is working." (James 5:16b) There he is speaking not of some internal change but of an actual power over the external world. He goes on to use the example of Elijah, by whose prayers the heavens were shut and then rain was caused to come.
Of course, this power cannot overrule what we said above. Jesus in the garden prays that He might be spared the cross, but famously says "not my will but Yours be done." (Luke 22:42) This must be implicit in all of our prayers, and it is where what we just said can go wrong. There are those who appropriate James's words in such a way that prayers which don't result in powerful acts of God are regarded as indicating some defect in the prayer. Nothing, though, could be further from the truth. Prayer does not put us in a place of sovereignty over God, and He will do as He pleases in the world.
However, prayer can be a means He sovereignly uses to work this pleasure. Scripture's insistence is that there are events in the world which would not occur without our prayers. There are people who are healed and saved and delivered from hardship because of prayer. God wills our prayers as the means through which He accomplishes remarkable things.
This means that prayer should be an avenue of humility and of hope. Humility because we recognize that we cannot force the hand of God. Hope, though, because we know that through prayer He might move in ways that seem otherwise impossible. God is at work in the world, and prayer is one of the main ways we join with this work and see it accomplished.