Yes, the secession of the Confederate states was illegal.
Secession was not strictly, or merely, a "legalistic" matter (see the last section, esp the concluding two paragraphs). However, to the extent that it was, the "legalistic" aspect is straightforward. In three sections: the law of the land, the arguments in support of the legality of secession, and why those arguments fail. Then two follow-up sections, on historiography and later legal commentators.
The Law of the Land
Secession has been illegal since the Articles of Confederation. No one ever mentions this, but the full title of that document was the "Articles of Confederation and Perpetual Union". (Emphasis added, obviously.) Article 13 said "And the Union shall be perpetual; nor shall any alteration at any time hereafter be made in any of them, unless such alteration be agreed to in a Congress of the United States, and be afterwards confirmed by the legislatures of every State."
The Articles created a much weaker national government, than the Constitution did. It follows that the "more perfect Union" created by the Consitution is, if possible, even more perpetual than the Perpetual Union created by the Ariticles: certainly not conditional, or "less perpetual". That's the exact reasoning used by the Supreme Court in Texas v White. The Constitution says it is the supreme law of the land: there's no room for a state government to suspend or nullify it.
The debates at the Constitutional Convention don't have much to say about secession – probably because the issue was already settled by the "perpetual" nature of the existing Union. There is a letter from Madison to Hamilton on the topic, from the Ratification era. Madison says "a reservation of the right to withdraw... is a conditional ratification... it does not make N. York a member of the New Union... she could not be received on that plan." (Letter to Hamilton)
Buchanan (of all people) made a similar argument. He pointed out some pretty strong negative evidence: in the long fight for Constitutional ratification, no one ever tried to persuade reluctant states by arguing that "the moment that any state felt herself aggrieved she might secede from the Union. ... What a crushing argument would this have proved against those who dreaded that the rights of the States would be endangered by the Constitution!" (From Buchanan's 4th annual message.) The absence of counter-evidence is not the same thing as evidence; but this actually is a strong point. Constitutional ratification was protracted and difficult, with extensive discussion by the leading political minds of the day. They didn't just FORGET to mention a right to withdraw, if one existed.
The argument in support of secession
The basic argument is that the states agreed to enter into the US Constitution, so they could decide to leave. But by itself that argument is severely flawed. Either party can opt NOT TO ENTER a contract; entering into a contract is voluntary. But once a contract is entered into, it takes BOTH parties to dissolve it. One party can't dissolve a contract unilaterally.
To support unilateral secession, supporters invoke what is called "Compact Theory": the Union is not a national government, but instead a compact of independent sovereigns, somewhat like a League of Nations. Nations can unilaterally rescind treaties. Compact Theory had a long and respectable pedigree in American politics. Jefferson and Madison were both proponents.
This is really the entire argument. The states are sovereign, they entered into a compact, and they can withdraw from at will.
Why the argument fails
Compact Theory had already been rejected by the Supreme Court in 1816, 44 full years before South Carolina seceded. The case was Martin v. Hunter's Lessee (1816). By the way, 4 of the 6 Justices who participated in that ruling were Southern (one of them was George Washington's nephew). The ruling was that the Constitution was not an agreement between the states at all; rather, as the preamble says, it was ordained and established directly by the people.
This decision was reiterated in McCulloch v. Maryland (1819); still 41 years before secession. 5 of the 7 sitting Justices in that case were Southern (still including the nephew); and the decision was unanimous. McCulloch extended Martin, saying that "the constitution and the laws made in pursuance thereof are supreme ... they are binding on the states and cannot be controlled by them."
Both cases draw a distinction between the Articles of Confederation, which were a "Compact" between sovereign states, and the Constitution, which is not. You can actually go back to Chisholm v. Georgia (1793) to see compact theory get its first beating from the Court. This was the original Court appointed by George Washington. That ruling was that the People directly established "a Constitution by which it was their will that the State governments should be bound." 1793! The 11th amendment undid part of Chisholm; but it conferred Sovereign Immunity, not Sovereignty. No justification for Compact Theory.
It's very straightforward. By 1820, Southern majorities of the Supreme Court had already rejected the only argument in support of the legality of secession, THREE TIMES. That's well before secession, and Texas v White.
If you're serious in asking the question (I suspect you are not), it's important to understand that in the historiography of the Civil War, this question is one of the Southern Apologist arguments. Saying that secession was legal until the Court issued its 1869 ruling in Texas v White, implies that there was no legal basis for the Court's ruling, ie it's pure judicial fiat. That's a pure Southern Apologist argument. The rest of the logic goes: "secession was not illegal until 1869, therefore secession was LEGAL up until 1869, therefore Lincoln's use of armed force to put down the slaveholders rebellion was illegal." The line of argument is used to paint Lincoln as a criminal, an aggressor, a dictator.
And it's not true. Texas v White was pure Stare Decisis: the law underpinning the decision had been settled back in 1816.
Later Legal Commentary
There is some discussion about whether later legal commentary contradicts the argument from the 1816 and 1819 rulings. At least three times since 2000, judges have stated that the question of a state's ability to secede was unsettled prior to the Civil War. That has occurred in a Supreme Court ruling, in a Supreme Court justice's correspondence, and in a state supreme court ruling.
"At the time, the phrase 'one Nation indivisible' had special meaning
because the question whether a State could secede from the Union had
been intensely debated and was unresolved prior to the Civil War." (
Elk Grove Unified Sch. Dist. v. Newdow, 542 U.S. 1, 6 n. 1, 124 S.Ct.
2301, 159 L.Ed.2d 98 (2004). )
"If there was any constitutional issue resolved by the Civil War, it
is that there is no right to secede."
- In 2010 the Alaska state supreme court wrote that:
"While a state's ability to secede was an unsettled question before
the end of the Civil War, subsequent United States Supreme Court
opinions have concluded that secession is clearly unconstitutional,
and Lincoln's belief in a perpetual Union is reflected in what we have
described as 'a plenitude of Supreme Court cases holding as completely
null' the acts of secession by Confederate states."
Is there a contradiction here?
No. It's important to note that none of these jurists (except for the second half of Alaska, after the word "subsequent") reference any legal action or court rulings. SCOTUS 2004 does NOT say, "the question whether a state could secede was unresolved prior to Texas v White." Scalia does not write, "the constitutional issue resolved by Texas v White is that there is no right to secede." The Alaska court does not say, "a state's ability to secede was unsettled before Texas v White." What they all mention is the war. All of these jurists are saying that the Civil War itself settled the question. Not any court ruling: the actual war.
And that's the truth. Secession was not a legalistic question that the courts could settle, by examining the Constitution and accumulated Supreme Court precedent. Look at the Dred Scott ruling: that was intended to settle the question of slavery in the territories, and of "negro" citizenship. It did not come anywhere close to doing that. Likewise secession. Secession was a political (and military!) question. It took the war to settle the matter.