God knows all things (things that are, things that were, things that will be, and things that could be.) He takes all of these into account and works out everything in conformity with the purpose of His will.1
This being true, there are things God does for us whether we ask Him or not, just as there are things God will not do for us even though we ask Him.
And finally, there are things God will only do for us if we ask Him.2
A good example of God doing something only in response to prayer is seen in the healing of King Hezekiah. Here's what is written in the Old Testament of the Bible about Hezekiah's illness and his healing from God:
In those days Hezekiah became ill and was at the point of death. The prophet Isaiah, son of Amoz, went to him and said, "This is what the LORD says: Put your house in order, because you are going to die; you will not recover."
Hezekiah turned his face to the wall and prayed to the LORD , "Remember, O LORD , how I have walked before you faithfully and with wholehearted devotion and have done what is good in your eyes." And Hezekiah wept bitterly.
Before Isaiah had left the middle court, the word of the LORD came to him: "Go back and tell Hezekiah, the leader of my people, ' This is what the LORD, the God of your father David, says: I have heard your prayer and seen your tears; I will heal you. On the third day from now you will go up to the temple of the LORD. I will add fifteen years to your life. And I will deliver you and this city from the hand of the king of Assyria. I will defend this city for
My sake and for the sake of My servant David.'"3
1 (Ephesians 1:11)
2 (James 4:2-3)
3 (2 Kings 20:1-6