There is more to say about prayer but this question begs a response. And here are my initial thoughts.
Perhaps God desires to be moved, to be affected by our prayers, by our communion with God. God’s will includes being in cooperative loving relationship with us. Like a father and mother with their child, waiting to be ‘asked’ so that he or she may be given, is the loving God who waits for us. This is not to say that every prayer uttered to God will bring an affirmative response and when a ‘no’ comes I believe, for myself anyway, that I need to stay in that communion.
See we don’t know what the ultimate will of God is and therefore it might be presumptuous to think we cannot change what we do not know. But according to the Bible God desires us to pray effectively for a ‘good’ response. So I would say that prayer affects God.
I think we read in Scripture how Moses pleaded with God to spare the Israelites and God changed his mind. Then the LORD relented and did not bring on his people the disaster he had threatened. (Exodus 32:14.) Or this in Hosea 11:8: My heart is turned within me: my compassion is aroused. There is also the story of King Hezekiah who, when told by God that he was going to die, pleaded for more years to live and God gave him those years. (Isaiah 38) You might say that this was already God’s intention and will but then I think that my own will as a dad with children is somehow affected in real-time by the requests of my children.
I realize there are passages in the Bible where it is said of God that God cannot or does not change but since we find both there in some kind of dialectical tension let’s consider that in some sense, that we may not fully understand, God allows God’s self to be changed in whatever human like attributes we may understand that concept.
God wants us to pray to God as in the parable of the wicked judge and the widow. In Luke 18 Jesus tells that story in order to encourage the disciples to pray and not give up. And he concludes by saying ‘will the son of man find faith when he returns?’ So faith therefore is asking, seeking, knocking for a response.
Recall the parable of the ‘friend at midnight’ from Luke 11. Jesus tells this parable to encourage his followers to keep asking God, seeking God and knocking on the gates of heaven for an answer. He concludes by saying God really wants to give his presence to us and I take it to thereby mean that in some way in prayer God and we are cooperating or relating.
See what Karl Barth has to write concerning our prayers affecting God. This quote comes from Philip Yancey in his book on Prayer.
“[Karl Barth, the 20th-century theologian who pounded home the theme of God’s sovereignty, saw no contradiction at all in a God who chooses to let prayers affect him.] He is a not deaf, he listens; more than that, he acts. He does not act in the same way whether we pray or not. Prayer exerts an influence upon God’s action, even upon his existence. That is what the word ‘answer’ means. … The fact that God yields to man’s petitions, changing his intentions in response to man’s prayer, is not a sign of weakness. He himself, in the glory of his majesty and power, has so willed it.”
Perhaps we might conclude that love always surrenders to the other. Love hears the other and connects with the other through heart and mind. If God is love God knows how best to relate to his people and this involves perhaps altering one’s plans. But first and foremost what I want to change is ME. I want God to change me more and more into his likeness so that what I request from God aligns so well with God’s will. At the very least we can say that prayer changes something and if that is the case the let us boldly approach God as our Sovereign Creator, Provider, and Friend.
Jesus told us that if we see him we see the Father. And in Jesus we see our God whose delight perhaps is to change circumstances in response to the sincere, heartfelt and unceasing prayers of his people. Why all things aren’t changed is in some respects a mystery I surmise that some of us already know why God says ‘no’.