One subtle point: there are sometimes legal processes for declaring independence from a host country.
The most clear example of this is the Statute of Westminster 1931, which the Parliament of the UK passed in order to create a legal process by which its colonies could file for legal independence.
As I understand it, in British law classes, there is often a question asked of students: "If Parliament repealed the Statute of Westminster today, would we (in principle, legally) get all of those colonies back? Does Parliament have the right to repeal the Statute of Westminster and the grants of independence under it, or were they something otherwise unprecedented in law: a surrender, effective forever, of certain legal powers?" Etc.
So yes, there are sometimes legal processes for starting a country, although the U.S. doesn't really have one. The U.S. does allow you to apply for statehood however, so it might be interesting to immediately declare independence (illegally) and then immediately apply to become a state (legally) to see which imperative wins out.