Accordingly in human government also, those who are in authority, rightly tolerate certain evils, lest certain goods be lost, or certain greater evils be incurred: thus Augustine says (De Ordine ii, 4): "If you do away with harlots, the world will be convulsed with lust."
Sounds like St. Thomas. Why? This principle doesn't necessitate the legalization of all vices.
For example, considering the current state of our society, I think it wise to continue the prohibition against prostitution (more good than harm), but the decriminalization of some drugs may result in less societal evil (i.e., the elimination of gang violence, but more overdoses and family damage/destruction).