Objection 1. It would seem unlawful to kill men who have sinned. For our Lord in the parable (Matthew 13) forbade the uprooting of the cockle which denotes wicked men according to a gloss. Now whatever is forbidden by God is a sin. Therefore it is a sin to kill a sinner.
(Snip)
On the contrary, It is written (Exodus 22:18): "Wizards thou shalt not suffer to live"; and (Psalm 100:8): "In the morning I put to death all the wicked of the land."
I answer that, As stated above (Article 1), it is lawful to kill dumb animals, in so far as they are naturally directed to man's use, as the imperfect is directed to the perfect. Now every part is directed to the whole, as imperfect to perfect, wherefore every part is naturally for the sake of the whole. For this reason we observe that if the health of the whole body demands the excision of a member, through its being decayed or infectious to the other members, it will be both praiseworthy and advantageous to have it cut away. Now every individual person is compared to the whole community, as part to whole. Therefore if a man be dangerous and infectious to the community, on account of some sin, it is praiseworthy and advantageous that he be killed in order to safeguard the common good, since "a little leaven corrupteth the whole lump" (1 Corinthians 5:6).(emphasis added)
Therefore, according to a Doctor of the Church, capital punishment is not solely an act of justice but is "praiseworthy and advantageous" for "the common good."
I love Saint Thomas Aquinas and his reasoning. Solid, Angelic, awesome. Unfortunately, he was not a pope and did not speak ex-cathedra - not saying nor implying Pope Francis is here. And no, I am not a big fan of Pope Francis, but he is the Pope and I am Catholic.