It is by your free will that God keeps the lines of communication open to hear all your prayers. He will not force you to seek Him nor to request counsel from Him. He only makes Himself available for you. Although God is Almighty and All-Knowing, He delights in having a relationship with us. He wants us to ask, seek, and knock. He has everything and wants to give us everything that is good for us. He teaches to pray on behalf of others and for the good of others. Is it for the purpose of changing God's mind? Not really, since He is All-Knowing and has perfect foreknowledge of all that is in the here and now, and all that is to come. However, through prayer, we enter into a deep and intimate dialog with God. God could have stopped the rain without Elijah's prayers, and the son of the widow could have certainly arisen without Elijah (1 Kings 17-18). But, Elijah, needed to pray and beseech God and God anticipated Elijah's petitions and responded to his prayers.
In the reflections of St. Ambrose regarding prayer, he teaches us how to humble ourselves before the Lord and to seek the most loving God who personifies humility at its best, for He chooses to not impose Himself on anyone, yet gladly welcomes all: "In prayer ... Let your door stand open to receive Him; unlock your soul to Him; offer Him a welcome in your mind, and then you will see the riches of simplicity, the treasures of peace, joy and grace. Throw wide the gate of your heart, stand before the sun in everlasting light that shines on every man. This true light shines on all, but if anyone closes his window, he will deprive himself of eternal light. If you shut the door of your mind, you shut out Christ. Though He can enter, He does not want to force His way in rudely, or compel us to admit Him against our will" (St. Ambrose).