It became necessary from the time of Adam that the Patriarchal system be adhered to. It was not until Cain left his family that other systems were set up under the direction of Cain who was under the influence of Satan. As the sons of Adam and those of Cain spread over the land it is no doubt that some for of stable form of government had to set up. As there are no earlier records other than those recorded in scripture we are not certain just how these governments were set up, that law and order was needed is a certainty. It is this writers opinion that both the result of anarchy and the need to bring the tribes into some sort of order was required.
The above is only an opinion.