The main reason why we have laws is that laws allow large groups of people to live together even though they are not related and do not have much in the way of connections with one another.
Imagine a world in which there were no laws. It would be very hard for people to live in close proximity to one another (as in a town or city). Without laws, there would be nothing to compel people to respect one another’s life, liberty, or property. If I wanted someone else’s possessions, I would take them by force. If I wanted to force someone to work for me, I could do so (assuming I was strong enough). If I wanted to kill someone, there would be nothing to stop me (except for the other person’s strength and ability to defend themselves). This is what political philosophers have called the “state of nature” in which all people are more or less in competition with all others in an environment where there are no limits on what they can do.
It would be possible for a few people to live together. We could live with our relatives and our close friends because we would have a reason not to mistreat them. We would treat them well because we felt a connection to them. This might work with a few other people, as long as we have close ties with them. But we would have no reason to treat people well if they were not closely connected to us. This would severely limit the number of people who could live together.
When we have laws and people to enforce them, it becomes possible to live together. I have to respect others’ life, liberty, and property because I will be punished by the law if I do not. This is the basis for our system of laws. It is designed to make sure that we all treat one another well enough to allow us to all live together in society.