2. It is suitable that God should fulfil our desires in so far as He moves us to desire. If therefore the movement of desire on our part is not kept up by earnestness in prayer, there is nothing to be surprised at if the prayer does not gain its due effect. Hence the Lord [St Luke] says: We ought always to pray and not to faint (Luke xviii, 1); and the Apostle, Pray without ceasing (i Thess. v, 17).
3. It befits God to hear the prayer of the rational creature inasmuch as that creature draws nigh to Him. But one draws nigh to God by contemplation and devout affection and humble and firm intention. That prayer therefore which does not so draw nigh to God is not within God's hearing. Hence it is said: He hath regarded the prayer of the humble (Ps. ci, 18); and, Let him ask in faith, debating not within himself (James i, 6).
4. God hears the prayers of the pious on the ground of friendship. He then who turns away from the friendship of God is not worthy to have his prayer heard.* Hence it is said: Whosoever turns away his ear from hearing the law, his prayer shall be abominable (Prov. xxviii, 9): Though ye multiply prayers, I will not hear: for your hands are full of blood (Isai. i, 15). This is why sometimes a friend of God is not heard, when he prays for those who are not God's friends, as it was said: Do not thou pray for this people, nor take unto thee praise and supplication for them, and do not withstand me: for I will not hear thee (Jerem. vii, 16).
It happens sometimes that for very friendship one denies his friend's petition, knowing it to be hurtful to him, or the contrary to be better for him, as a physician refuses what his patient asks for. No wonder then if God, who fulfils the desires put before Him by His rational creature for the love that He bears to that creature, fails sometimes to fulfil the petition of those whom He singularly loves, that He may fulfil it otherwise with something more helpful to the salvation of the petitioner, as we read in 2 Cor. xii, 7-9; and the Lord says to some: Ye know not what ye ask (Matt. xx, 22). Therefore Augustine says (Ep. ad Paulin. et Theras.): "The Lord is good in often not giving what we will, to give instead what we should prefer."
3.95, 96 : That the Immutability of Divine Providence does not bar the Utility of Prayer
3.97 : How the Arrangements of Divine Providence follow a Plan