One of the oldest and strongest limitations on liberty is that governments can act — via the so-called “police powers” of the states — to protect the health and welfare of the public:
It is very clear and well settled that the statutes are not obnoxious to the objection of unconstitutionality, which is the other point argued by the plaintiffs. It is unquestionable, that the legislature can confer police powers upon public officers, for the protection of the public health. The maxim salus populi suprema lex is the law of all courts and countries. The individual right sinks in the necessity to provide for the public good. The only question has been, as to the extent of the powers that should be conferred for such purposes.
— Haverty v. Bass, 66 Me. 71 (1876)
The rather more famous Lochner v. New York, normally cited as the pre-eminent case supporting the now-discredited judicially protected concept of liberty of contract, allows that “general welfare” restrictions, exercised through these same “police powers,” are capable of restricting even their precious economic freedoms:
The general right to make a contract in relation to his business is part of the liberty of the individual protected by the Fourteenth Amendment of the Federal Constitution. Allgeyer v. Louisiana, 165 U.S. 578. Under that provision no State can deprive any person of life, liberty or property without due process of law. The right to purchase or to sell labor is part of the liberty protected by this amendment, unless there are circumstances which exclude the right. There are, however, certain powers, existing in the sovereignty of each State in the Union, somewhat vaguely termed police powers, the exact description and limitation of which have not been attempted by the courts. Those powers, broadly stated and without, at present, any attempt at a more specific limitation, relate to the safety, health, morals and general welfare of the public.
— Lochner v. New York, 198 US 45 (1905)
As a result the power of state governments to restrict liberty in the name of public health has endured throughout the history of the United States, allowing even for rather extreme measures like forced (at the end of a police club, at times) vaccination, mandatory quarantines, and even the forcible transport and incarceration of citizens suspected of being infected with diseases like smallpox — actions taken most commonly late in the nineteenth century, when some have maintained the United States was at its most libertarian.