Tribal customs are, needless to say, a bit different from rules concerning societies of thousands, to hundreds of thousands of people. Became impossible for people to maintain the tribal system once populations became that large. Law in some simplistic sense has existed for as long as there have been civilizations. There is a collect of rules, they are outlined, you are expectd to follow them, and in case you don't, they are enforced. That's pretty much all it takes. These rules, as well as officials to define and enforce them, were established because populations and territories became too large for things to be operated on entirely interpersonal basis.
You now had a situation where two people in society may never have even met. A goverment, even if a simple one, was necessary to hold it together.
Government not an foreign artifice. Government is
a part of human nature. It is the by-product of our social habits when our population exceeds tribal sizes. Tribe becomes Chiefdom, Chiefdom becomes nation. It is inevitable. It is intuitive.