I’ll start by recognizing that whatever Aquinas said is likely to be right.
And I have recognized this as well. This (times when capital punishment would be harmful), however, explains the exception to the rule. I think also you have a limited view of what the “common good” means, because it means a good deal more than simply maintaining order in society. The term is actually much broader and includes the order of justice:*When the second edition of the Catechism of the Catholic Church appeared in 1997, some readers were surprised to discover that the purpose of capital punishment as restitution of public order had been removed from the discussion *(Archbishop Wilton Gregory)
1906 By common good is to be understood **“the sum total of social conditions which allow people, either as groups or as individuals, to reach their fulfillment more fully and more easily.”**26 The common good concerns the life of all. It calls for prudence from each, and even more from those who exercise the office of authority. It consists of three essential elements:
1907 First, the common good presupposes respect for the person as such. In the name of the common good, public authorities are bound to respect the fundamental and inalienable rights of the human person. Society should permit each of its members to fulfill his vocation. In particular, the common good resides in the conditions for the exercise of the natural freedoms indispensable for the development of the human vocation, such as "the right to act according to a sound norm of conscience and to safeguard . . . privacy, and rightful freedom also in matters of religion."27
1908 Second, the common good requires the social well-being and development of the group itself. Development is the epitome of all social duties. Certainly, it is the proper function of authority to arbitrate, in the name of the common good, between various particular interests; but it should make accessible to each what is needed to lead a truly human life: food, clothing, health, work, education and culture, suitable information, the right to establish a family, and so on.28
1909 Finally, the common good requires peace, that is, the stability and security of a just order. It presupposes that authority should ensure by morally acceptable means the security of society and its members. It is the basis of the right to legitimate personal and collective defense.