Original Intention of Rules(Laws) in human societies :

Laws or community rules originally had a purpose to define common guidelines to facilitate a peaceful coexistence in congestion areas (everywhere where a significant number of people come together).
An important task of laws was, to safeguard the rights (space, freedoms) of individuals by defining clearly the borders of these individual rights and some interaction rules between individuals and groups.
Laws were intended as a formalized system to enable justice / just decisions in cases of conflicting individual freedoms.