No, secession is not illegal. There is nothing in the U.S. Constitution that prohibits a state from choosing to leave the union. And the Constitution is the supreme law of the United States.
British colonists founded the United States when they decided to secede from Great Britain. The Declaration of Independence spells out their rationale beautifully:
Excerpt from the U.S. Declaration of Independence
When in the Course of human events, it becomes necessary for one people to dissolve the political bands which have connected them with another, and to assume among the powers of the earth, the separate and equal station to which the Laws of Nature and of Nature’s God entitle them, a decent respect to the opinions of mankind requires that they should declare the causes which impel them to the separation.
We hold these truths to be self-evident, that all men are created equal, that they are endowed by their Creator with certain unalienable Rights, that among these are Life, Liberty and the pursuit of Happiness.–That to secure these rights, Governments are instituted among Men, deriving their just powers from the consent of the governed,
That whenever any Form of Government becomes destructive of these ends, it is the Right of the People to alter or to abolish it, and to institute new Government, laying its foundation on such principles and organizing its powers in such form, as to them shall seem most likely to effect their Safety and Happiness. Prudence, indeed, will dictate that Governments long established should not be changed for light and transient causes; and accordingly all experience hath shewn, that mankind are more disposed to suffer, while evils are sufferable, than to right themselves by abolishing the forms to which they are accustomed. But when a long train of abuses and usurpations, pursuing invariably the same Object evinces a design to reduce them under absolute Despotism, it is their right, it is their duty, to throw off such Government, and to provide new Guards for their future security.
If American colonists had the right to declare their independence from Great Britain, then modern Americans have that same right.
New Hampshire Right of Revolution
In New Hampshire, our state constitution includes a “right of revolution” in its Bill of Rights:
[Art.] 10. [Right of Revolution.] Government being instituted for the common benefit, protection, and security, of the whole community, and not for the private interest or emolument of any one man, family, or class of men; therefore, whenever the ends of government are perverted, and public liberty manifestly endangered, and all other means of redress are ineffectual, the people may, and of right ought to reform the old, or establish a new government. The doctrine of nonresistance against arbitrary power, and oppression, is absurd, slavish, and destructive of the good and happiness of mankind.Article 10 of the New Hampshire Constitution
Supreme Court Ruling
There was a U.S. Supreme Court case (Texas vs White 1869) that ruled that unilateral secession is illegal. But in the same case, the Court commented:
“The union between Texas and the other States was as complete, as perpetual, and as indissoluble as the union between the original States. There was no place for reconsideration or revocation, except through revolution or through consent of the States.”
“… except… through consent of the States” implies that, if the States cease to consent, there’s a place for reconsideration!
Modern Examples of Secession
The U.S. federal government formally recognizes numerous countries created via secession. One example is Algeria, the largest country (by territory) in Africa. It was a French colony until it gained its independence from France in 1962. France is a close ally of the U.S. In fact, it was the first nation to establish diplomatic relations with the U.S. when it seceded from Great Britain. But the U.S. now recognizes Algeria’s sovereignty, and maintains a consulate in Algiers.
Currently, the U.S. government, media, and public are lending a great deal of support to the nation of Ukraine. Note that Ukraine only became independent from Russia on July 16, 1990. It did so by adopting a Declaration of State Sovereignty of Ukraine. Sounds similar to what the U.S. founding fathers did!