St. Thomas observes that although reason is what directs the law, there must be something upon which reason is focused, the ultimate end or purpose (what is called the "final cause"). With respect to law, that focus must be the common good. The common good is based upon happiness; this happiness is "the principle in respect of all the rest." ST IaIIae, Q.90, art. 2, resp. From a natural perspective, this happiness is Aristotle's eudaemonia, what St. Thomas calls felicitas, felicity. From a supernatural perspective, this happiness is what is referred to as beatitude or eternal joy, what St. Thomas calls beatitudo.
The happiness that the law is concerned with is not any individual's happiness, but the happiness of the entire body politic, that is, the universal happiness, or happiness of the community (felicitatem communem). The law, therefore, must not have any particular individual's happiness as its end, but, rather, the happiness of the entire body politic. Quoting Aristotle, St. Thomas states that the only just law is that law which is adapted to produce and preserve happiness for the the body politic. See Aristotle, Ethics, v. 1. The law, can address individual things, and it may result in one particular individual's or one group's happiness. In itself, that is not defective so long as the law was ordained to the good of the community. It is only when the law is not it is ordered to the common good, but toward the good of a group or an individual, that it is "devoid of the nature of law" (non habeat rationem legis). ST IaIIae, Q. 90, art. 2, resp.; see also id. resps.1, 2. Thomas thus strikes a balance between individualism and collectivism.
Nathanael Culverwell describes what occurs when the law is ordered toward the common good
Law-givers should send out laws with Olive-branches in their mouths, they should be fruitful and peaceable; they should drop sweetness and fatness upon a land. Let not then Brambles make laws for Trees, lest they scratch them and tear them, and write their laws in blood. But Law-givers are to send out laws, as the Sun shoots forth his beams, with healing under their wings: and thus that elegant Moralist Plutarch speaks, God (says he) is angry with them that counterfeit his thunder and lightning, οὐσκηπτρον, οὐκεραυνὸν, οὐτρίαιναν; his Scepter, and his Thunderbolt, and his Trident, he will not let them meddle with these. He does not love they should imitate him in his absolute dominion and sovereignty; but loves to see them darting out those warm, and amiable, and cherishing ἀκτινοβολίαι, those beamings out of Justice, and goodness, and clemency. And as for Laws, they should be like so many green and pleasant pastures, into which these ποιμένεςλαων [shepherds of nations] are to lead their flocks, where they may feed sweetly and securely by those refreshing streams of justice, that run down like water, and righteousness like a mighty torrent. And this consideration would sweep down many cobweb-laws, that argue only the venom and subtilty of them that spin them; this would sweep down many an Achitophel's web and many an Haman's web, many an Herod's web; every spider's web that spreads laws only for the catching and entangling of weaker ones; such Law-givers are fit to be Domitian's play-fellows, that made it his Royal sport and pastime to catch flies, and insult over them when he had done. Whereas a Law should be a staff for a Commonwealth to lean on, and not a Reed to pierce it through. Laws should be cords of love, not nets and snares. Hence it is that those laws are most radical and fundamental, that principally tend to the conservation of the vitals and essentials of a Kingdom; and those come nearest the Law of God himself, and are participations of that eternal Law, which is the spring and original of all inferior and derivative laws. του ἀρίστου ἕνεκα πάντα τὰ νόμιμα [all laws exist for the sake of the good], as Plato speaks; and there is no such public benefit, as that which comes by laws; for all have an equal interest in them, and privilege by them. And therefore as Aristotle speaks most excellently, Νόμος ἐστὶ νους ἄνευὀρέξεως. A Law is a pure intellect, not only without a sensitive appetite, but without a will. ’Tis pure judgment without affections, a Law is impartial and makes no factions; and a Law cannot be bribed though a Judge may.
(from An Elegant and Learned Discourse of the Light of Nature, ed. Robert A. Greene and Hugh MacCallum, (Indianapolis: Liberty Fund, 2001) (spelling modernized).)