Most human societies and cultures have rules to ensure a certain level of fairness and safety for their citizens and inhabitants. Rules and systems of implementing rules allow human groups to function despite friction between members.
Rules exist on multiple levels, and not every society shares the same rules. Rules are ultimately based on a culture's value system. Over time, some values become ingrained in the culture as methods of determining what one should or should not do, called morals. A governing body can turn rules into laws by making a declaration of illegality, usually including a punishment if the law is broken. Some rules can hurt members of a society, but without any rules, there could be no effective way to ensure that people are treated equally.