It's a matter of logic. Everything is under God's control. It's in the job description. How can this fact be reconciled with the fact that God is all good? Logically, He must allow evil only in order that a greater good may come.
For Aquinas, God is the cause of things by causing their existence. Evil is a privation, i.e. it is the lack of some due perfection or existence in something that already has existence. There can be nothing that is "pure evil;" an evil thing is first a thing. Consequently it has some existence, and so has some good, of which God is the cause. Since evil is the lack of existence, God is not the direct, i.e. per se, cause of it; He is the cause of evil only indirectly, i.e. per accidens, insofar as He causes things to exist in which there is found some evil. So, Aquinas believes that the existence of God can be proved from the fact that things exist and do not cause their own existence. This being so, i.e. that God exists, the existence of evil does not undercut the proof, since even the existence of evil presupposes the existence of things. Thus, the answer to the problem of evil is whether God, while not directly willing evil, can indirectly allow evil and still be all-good and all-powerful. His answer is that God is so powerful, that He allows evil in order to bring good from it. Ultimately, I think, Aquinas does not show HOW this is the case in every evil we experience. He believes, however, THAT it must be the case, since we already know that God exists and that He is all-powerful and all-good.
However, if one is of the opinion that God does not always intervene to make sure that good things happen to good people, then it's not much of a stretch to also believe that he's not taking an active role in all the bad things that happen.
It's a question of whether God directly intervenes in everything that happens, or whether he allows events to occur naturally.
I hold the latter opinion, and believe that prayer is the asking for active intervention which might otherwise be withheld.