All laws, whether codified or not and whether evolved or imposed by conquest or revolution rest on the foundations of the underlying social structures that existed prior to the law's "discovery" or enactment. It isn't just in common law countries that basic legal concepts can be traced back to the customs of earlier social formations. Roman Law and the Code Napoleon did not spring from some emperor's head but from the actual social realities.
But that is a different question from how legal systems are established. They also emerge from existing social relations but when one legal system replaces another it is because social relations were changed by force and contrary to the laws of the previous legal system.
Consider the proposition that "tyranny is unlawful" as a future tenet of customary international law.
The proposition that "slavery is unlawful" was enforced unilaterally by the British navy on the high seas before it became accepted even in the United States. This was denounced as a totally arbitrary violation of the lawful rights of peaceable slavers and if America had had a navy as powerful as Britains it would never have been tolerated.
It only became accepted as international law much later. Saudi Arabia for example only abolished chattel slavery in the 1960s. Nevertheless it is now law (and like many other laws often breached with forms of slavery still quite widespread even though illegal).
At present the proposition that "tyranny is unlawful" is so novel that it would have been nonsensical to even present it as a casus belli. Some other excuse had to be found to provide a legal pretext for invading Iraq.
One may reasonably hope that this novel principle will eventually be accepted as "conventional wisdom" and customary law reflecting the actual practice of states when confronted with the international crime of tyranny.
When that happens it will be possible to trace a long history of customs relating to tyranny and in particular a long standing practice of tyrants coming to a sticky end and their successors proclaiming that they were overthrown because they were tyrants. An early discussion can be found in Xenophon's Hiero or Tyrannicus.
Judges labouring in the vineyards of the law will "discover" new principles that were in fact grown from the seeds planted there by agitators - generations before any lawyer could comprehend what they were agitating about and will write lengthy treatises on the development of the crime of tyranny.
Nevertheless, the establishment of a system of international law in which tyranny is itself unlawful has not yet been achieved. When it is achieved it will mark a different international legal system from the present one.
An important step towards that new understanding of international law has just been taken and it is the near unanimous view of international lawyers that it was plainly an illegal war.
Indeed the arguments that invading a country to overthrow a tyranny is currently lawful are as preposterous as Dred Scott's claim that words asserting a right to life liberty and the pursuit of happiness were intended to apply to people like him - people who were in fact well understood by the founding fathers to be slaves at the time they wrote those words.
The US Supreme Court's decision on that case could not be overturned by law, but only by civil war.
Even during the civil war, Lincoln was only able to issue an Emancipation Proclamation with respect to "enemy property" ie slaves owned in the Confederate States - but not in the border states where slavery remained lawful.
It was so clear that slavery was lawful that Lincoln had to launch the war on the pretext of "defending the Union" and deny any intention of freeing the slaves.
Unfortunately as each battle is won it remains in the interests of ruling classes to discourage the idea that change arises from breaking laws and overthrowing states by force.
The revolutionaries become conservatives and pretend that their rule is from time immemorial.
In Britain it even went to the absurdity of declaring that the Protestant successors of Princess Sophia, Electress of Hanover reign over the republic - just to pretend the monarchy wasn't overthrown by force.
Nevertheless, legal systems are established by force, not by law.