Divine Providence does not entirely Exclude Evil from Things
Summa Contra Gentiles, Book III, c. 71
Now, from these conclusions it becomes evident that divine providence, whereby He governs things, does not prevent corruption, deficiency, and evil from being found in things.
Indeed, divine governance, whereby God works in things, does not exclude the working of secondary causes, as we have already shown [See above, ch. 69-70]. Now, it is possible for a defect to happen in an effect, because of a defect in the secondary agent cause, without there being a defect in the primary agent. For example, in the case of the product of a perfectly skilled artisan, some defect may occur because of a defect in his instrument. And again, in the case of a man whose motive power is strong, he may limp as a result of no defect in his bodily power to move, but because of a twist in his leg bone. So, it is possible, in the case of things made and governed by God, for some defect and evil to be found, because of a defect of the secondary agents, even though there be no defect in God Himself.
Moreover, perfect goodness would not be found in created things unless there were an order of goodness in them, in the sense that some of them are better than others. Otherwise, all possible grades of goodness would not be realized, nor would any creature be like God by virtue of holding a higher place than another. The highest beauty would be taken away from things, too, if the order of distinct and unequal things were removed. And what is more, multiplicity would be taken away from things if inequality of goodness were removed, since through the differences by which things are distinguished from each other one thing stands out as better than another; for instance, the animate in relation to the inanimate, and the rational in regard to the irrational. And so, if complete equality were present in things, there would be but one created good, which clearly disparages the perfection of the creature. Now, it is a higher grade of goodness for a thing to be good because it cannot fall from goodness; lower than that is the thing which can fall from goodness. So, the perfection of the universe requires both grades of goodness. But it pertains to the providence of the governor to preserve perfection in the things governed, and not to decrease it. Therefore, it does not pertain to divine goodness, entirely to exclude from things the power of falling from the good. But evil is the consequence of this power, because what is able to fall does fall at times. And this defection of the good is evil, as we showed above [See above ch. 7]. Therefore, it does not pertain to divine providence to prohibit evil entirely from things.
Again, the best thing in any government is to provide for the things governed according to their own mode, for the justice of a regime consists in this. Therefore, as it would be contrary to the rational character of a human regime for men to be prevented by the governor from acting in accord with their own duties - except, perhaps, on occasion due to the need of the moment - so, too, would it be contrary to the rational character of the divine regime to refuse permission for created things to act according to the mode of their nature. Now, as a result of this fact, that creatures do act in this way, corruption and evil result in things, because, due to the contrariety and incompatibility present in things, one may be a source of corruption another. Therefore, it does not pertain to divine providence to exclude evil entirely from the things that are governed.
Besides, it is impossible for an agent to do something evil, unless by virtue of the fact that the agent intends something good, as is evident from the foregoing [See above ch. 3-4]. But, to prohibit universally the intending of the good for the individual on the part of created things is not the function of the providence of Him Who is the cause of every good thing. For, in that way, many goods would be taken away from the whole of things. For example, if the inclination to generate its like were taken away from fire (from which inclination there results this particular evil which is the burning up of combustible things), there would also be taken away this particular good which is the generation of fire and the preservation of the same according to its species. Therefore, it is not the function of divine providence totally to exclude evil from things.
Furthermore, many goods are present in things which would not occur unless there were evils. For instance, there would not be the patience of the just if there were not the malice of their persecutors; there would not be a place for the justice of vindication if there were no offenses; and in the order of nature, there would not be the generation of one thing unless there were the corruption of another. So, if evil were totally excluded from the whole of things by divine providence, a multitude of good things would have to be sacrificed . And this is as it should be, for the good is stronger in its goodness than evil is in its malice, as is clear from earlier sections [See above ch. 11-12]. Therefore, evil should not be totally excluded from things by divine providence.
Moreover, the good of the whole takes precedence over the good of a part. It is proper for a governor with foresight to neglect some lack of goodness in a part, so that there may be an increase of goodness in the whole. Thus, an artisan hides the foundations beneath earth, so that the whole house may have stability. But, if evil were removed from some parts of the universe, much perfection would perish from the universe, whose beauty arises from an ordered unification of evil and good things. In fact, while evil things originate from good things that are defective, still, certain good things also result from them, as a consequence of the providence of the governor. Thus, even a silent pause makes a hymn appealing. Therefore, evil should not have been excluded from things by divine providence.
Again, other things, particularly lower ones, are ordered to man's good as an end. Now, if no evils were present in things, much of man's good would be diminished, both in regard to knowledge and in regard to the desire or love of the good. In fact, the good is better known from its comparison with evil, and while we continue to suffer certain evils our desire for goods grows more ardent. For instance, how great a good health is, is best known by the sick; and they also crave it more than do the healthy. Therefore, it is not the function of divine providence totally to exclude evils from things.
For this reason, it is said: "I make peace and create evil" ( Isa. 45:7; Douay modified); and again: "There is no evil in a city which God will not do" (Amos 3:6) .
Now, with these considerations we dispose of the error of those who, because they noticed that evils occur in the world, said that there is no God. Thus, Boethius introduces a certain philosopher who asks: "If God exists, whence comes evil?" [Boethius, De consolatione philosophiae, I, prose 4 (PL, 63, col. 625]. But it could be argued to the contrary: "If evil exists, God exists". For, there would be no evil if the order of good were taken away, since its privation is evil. But this order would not exist if there were no God.
Moreover, by the foregoing arguments, even the occasion of error is removed from those who denied that divine providence is extended to these corruptible things, because they saw that many evils occur in them; they said, moreover, that only incorruptible things are subject to divine providence, things in which no defect or evil part is found [See Maimonides, Guide for the Perplexed, III, 17(ed. Friedländer, p. 282) who gives this as Aristotle’s view; see also Averroes, In Metaphysicam, XII, comm.. 52 (VIII, 337). Compare St. Thomas, Summa Theologiae, I, 22, 2c]
By these considerations, the occasion of erring is also taken away from the Manicheans who maintained two first agent principles, good and evil, as though evil could have no place under the providence of a good God [See St. Augustine, De haeresibus, 46 (PL, 42, col. 34)].
So, too, the difficulty of some people is solved; namely, whether evil actions are from God. Indeed, since it has been shown [See above, ch. 66ff] that every agent produces its action by acting through the divine power, and, consequently that God is the cause both of all effects and all actions, and since it was also shown [See above ¶ 2] that evil and defects occur in things ruled by divine providence as a result of the establishment of secondary causes in which there can be deficiency, it is evident that bad actions, according as they are defective, are not from God but from defective proximate causes; but, in so far as they possess something of action and entity, they must be from God. Thus limping arises from the motive power, in so far as it possesses something of motion, but in regard to what it has by way of defect it is due to the crookedness of the leg.
Summa contra Gentiles, Book III, c. 71, translated by James F. Anderson (Notre Dame - London: University of Notre Dame Press, 1995), pp. 237-242.