And this he said to show the Spirit's great concern about us, and also to instruct them not to think for certainty that those things are desirable which to man's reasonings appear so. For since it was likely that they, when they were scourged, and driven out, and suffering grievances without number, should be seeking a respite, and ask this favor of God, and think it was advantageous to them, by no means (he says) suppose that what seem blessings to you really are so. For we need the Spirit's aid even to do this. So feeble is man, and such a nothing by himself. For this is why he says, “For we know not what we should pray for as we ought.” In order that the learner might not feel any shame at his ignorance, he does not say, you know not, but, “we know not.” And that he did not say this merely to seem moderate, he plainly shows from other passages. For he desired in his prayers unceasingly to see Rome. Yet the time when he obtained it was not at once when he desired it. And for “the thorn” that was given him “in the flesh”, that is the dangers, he often besought God, and was entirely unsuccessful. And so was Moses, who in the Old Testament prays to see Palestine, and Jeremiah when he made supplication for the Jews, and Abraham when he interceded for the people of Sodom. “But the Spirit Itself makes intercession for us with groanings which cannot be uttered.” This statement is not clear, owing to the cessation of many of the wonders which then used to take place. Wherefore I must needs inform you of the state of things at that time, and in this way the rest of the subject will be cleared. What therefore was the state of things then? God did in those days give to all that were baptized certain excellent gifts, and the name that these had was spirits. For “the spirits of the Prophets,” it says, “are subject to the prophets.” And one had the gift of prophecy and foretold things to come; and another of wisdom, and taught the many; and another of healings, and cured the sick; and another of miracles, and raised the dead; another of tongues, and spoke different languages. And with all these there was also a gift of prayer, which also was called a spirit, and he that had this prayed for all the people. For since we are ignorant of much that is profitable for us and ask things that are not profitable, the gift of prayer came into some particular person of that day, and what was profitable for all the whole Church alike, he was the appointed person to ask for in behalf of all, and the instructor of the rest. Spirit then is the name that he gives here to the grace of this character, and the soul that receives the grace, and intercedes to God, and groans. For he that was counted worthy of such grace as this, standing with much compunction, and with many mental groanings falling before God, asked the things that were profitable for all. And of this the Deacon of the present day is a symbol when he offers up the prayers for the people. This then is what Paul means when he says, “the Spirit itself makes intercession for us with groanings that cannot be uttered.”
Ver. 27. “But He that searches the hearts.”
You see that it is not about the Comforter that he is speaking, but about the spiritual heart. Since if this were not so, he ought to have said, “He that searches” the Spirit. But that you may learn that the language is meant of a spiritual man, who has the gift of prayer, he proceeds, “And he that searches the hearts knows what is the mind of the Spirit,” that is, of the spiritual man.
“Because he makes intercession for the saints according to the will of God.”
Not (he means) that he informs God as if ignorant, but this is done that we may learn to pray for proper things, and to ask of God what is pleasing to Him. For this is what the “according to God” is. And so this was with a view to solace those that came to Him, and to yield them excellent instruction. For He that furnished the gifts, and gave besides blessings without number, was the Comforter. Hence it says, “all these things works one and the self-same Spirit.” And it is for our instruction that this takes place, and to show the love of the Spirit, it condescends even to this. And it is from this that the person praying gets heard, because the prayer is made “according to the will of God.”
Source: Homilies on Romans (New Advent)