As an intellectual and moral matter, the rights to self-government, free speech, self-defense, etc are based on the notion they are inherent to our existence and given by God.
As a practical matter, they are based on violence, on the use of force -- the Founding Fathers and the Continental Army and militias beat the British. There was no "legal" basis for us to separate -- King George III and his government wanted to hang our forefathers as traitors, and he would have been quite "legal" in doing so. Having created a separation -- a secession -- by force, we created a new legal basis among ourselves and agreed to abide by it. (For that matter, all law is ultimately about violence, the legal system simply adjudicates who gets to do "legal" violence to whom, and for what reasons). Ultimately there was a treaty signed between Britain and the confederation of American states -- I suppose that could be said to be a "legal" basis, but it was ratification of a secession already established by force.
The US Constitution and the laws derived from it (and the laws not derived from it!) do not provide for dismantling the US --there is no "legal" way to secede, there is no mechanism that via constitutional article nor legal statute provides for secession.
Do not confuse what might be "right", God-given or otherwise, with what is "legal." We try to get them to overlap, but they are not always 100% congruent.