How can revolution be "illegal?"

“Dr. Benjamin Franklin: A rebellion is always legal in the first person, such as “our rebellion.” It is only in the third person - “their rebellion” - that it becomes illegal.”

And is pretty widely accepted in principle as well as in theory.

There are two “crimes”, which, if successful, will not/cannot be prosecuted:

Rebellion
Suicide

One removes the prosecutor, the other the perpetrator.

It’s not a million miles away from the Montevideo Convention definition (of a nation-state), which has the status of an international norm today:

Note also that John Brown was hanged (before the War) for treason, murder, and inciting a slave insurrection.

There is no State that wants the means of it’s violent demise to be legal. That would be a suicide pact against Public Order, as violent protest and mayhem could not be legally suppressed as long as as a claim was made that it was “Revolution”.

And do you suppose for two seconds that the “Revolution” that took over a country so stupid as to allow such a thing wouldn’t themselves instantly pass a law making a violent overthrow of their regime illegal?

From Shogun:

Charles I’s defence at his trial rested on precisely this point - that those trying him had no standing or authority to do so:

There is no legal answer - there was in fact no-one with power to bring the King to trial. As that precise constitutional point was one of the root causes of the Civil War that had brought Charles to this pass, however, it was unlikely that it would succeed as an argument now. His reliance on it as a legal strategy is a neat demonstration of both his stubborn adherence to his principles and his disregard for practical consequences. Which in this case, were quite severe.