In the beginning there was no government, no courts, and no laws - except that one thing God said must not be done.
There was only one rule: “Don’t eat from the tree of knowledge of good and evil”. God ruled the Garden of Eden, and but for his one rule, there was no need to regulate any aspect of his creation. But of course, we know that sin changed everything.
Once there was evil as a result of sin, then there was a need to control it. So God took the first move in regulating human behavior. Yes, human behavior - one could argue this is essentially the reason we’ve ever had any need for government at all. Thomas Aquinas observed that “every law is framed for the direction of human actions”.1
If we had no sin (evil) in our world, then there would be no need to control human behavior. But we’ve had sin in our world for a long time, and our God - our Creator - is not surprised.
So God first punished sin and controlled human behavior by expelling Adam and Eve from the Garden of Eden with the means in place to deny any reentry (Genesis 3:23-24). Later, he placed a mark on Cain to prevent anyone from killing him as another control measure for human behavior (Genesis 4:15).
God continued to provide controls to mankind, for example the Mosaic law, or as we know it - the Ten Commandments. At the same time other peoples were subjected to human authorities such as a king. Eventually, God’s people who were subject to the laws of Moses came under the jurisdiction of other, man-made laws and kings. And the Bible teaches us that God establishes and removes kings as we see throughout the Book of Daniel (e.g. Daniel 2:21). By the way we have another Bible study on the Book of Daniel for you here.
Read Galatians 3:19. The ESV version is provided below. From that reading, what's the purpose of God’s laws given to Moses?