Here are the footnotes from the Aquinas Study Bible on this passage
13:1-2 By higher powers are meant person vested with political power for governing and ruling others, whether kings, princes, magistrates, etc. (Bishop John McEvilly) They have no power in spiritual matters, so that they do not receive the key of the heavenly kingdom. Their power is confined to temporal matters, and this too can only come to them from God, (Sum Theo 3.19.3.r2) But their laws may be unjust in two ways: first, by being contrary to human good—either in respect of the end, as when an authority imposes on his subjects burdensome laws, conducive, not to the common good, but rather to his own cupidity or vainglory—or in respect of the author, as when a man makes a law that goes beyond the power committed to him—or in respect of the form, as when burdens are imposed unequally on the community, although with a view to the common good. The like are acts of violence rather than laws; because, as Augustine says (De Lib. Arb. i, 5), “a law that is not just, seems to be no law at all.” Wherefore such laws do not bind in conscience, except perhaps in order to avoid scandal or disturbance, for which cause a man should even yield his right, according to Mat. 5:40,41: “If a man . . . take away thy coat, let go thy cloak also unto him; and whosoever will force thee one mile, go with him other two.” Secondly, laws may be unjust through being opposed to the Divine good: such are the laws of tyrants inducing to idolatry, or to anything else contrary to the Divine law: and laws of this kind must nowise be observed, because, as stated in Acts 5:29, “we ought to obey God rather than man.” (St. Thomas Aquinas Sum Theo 2.96.4.a)
13:4 sword: It is clear that, for the purposes of punishment to be achieved, the nature and extent of the punishment must be carefully evaluated and decided upon, and the state ought not go to the extreme of executing the offender except in cases of absolute necessity: in other words, when it would not be possible otherwise to defend society. Today however, as a result of steady improvements in the organization of the penal system, such cases are very rare, if not practically non-existent. (Pope John Paul II, Evangelium Vitae 56) While the Church exhorts civil authorities to seek peace, not war, and to exercise discretion and mercy in imposing punishment on criminals, it may still be permissible to take up arms to repel an aggressor or to have recourse to capital punishment. There may be a legitimate diversity of opinion even among Catholics about waging war and applying the death penalty, but not however with regard to abortion and euthanasia. (Joseph Cardinal Ratzinger Prior to his election as pope,Worthiness to Receive Communion – General Principles," July 2004)
**13:6-7 pay all of them their dues: **From this it is clear that justice requires subjects to render rulers their due: “To the king was brought one who owed him ten thousand talents” (Mt 18:24); “Render, therefore, to Caesar the things that are Caesar’s and to God the things that are God’s” (Mt 22:21). Secondly, he specifies debts that are paid publicly, saying: taxes to whom taxes are due: for these are paid to the ruler that he might govern the country in peace and quiet: “He saw that a resting place was good, and that the land was pleasant” (Gen 49:15). Revenue to whom revenue is due:
This is paid to the ruler in certain places as tolls, for the repair of roads and for safe travel. (St. Thomas Aquinas)