Rules and laws serve many purposes necessary for a thriving society, including the punishment of wrongdoers, the resolution of disputes, the promotion of the common good and moral habituation. The fact that every organized social institution, including families, schools and countries, have recognized rules shows humans' dependence on established codes of conduct.
Pearson Education identifies four primary functions of law. Laws serve to protect people from evil. Every society has individuals willing to harm others. Law creates a framework for reducing crime. First, it lays out the nature of proper and improper human conduct. It proscribes punishment for delinquency as a deterrent, and establishes the creation of enforcement mechanisms, such as police, that both prevent crime and enact punitive measures.
Law also promotes the common good. Humans tend to act out of self-interest. However, there are cases in which everyone benefits by pursuing a common interest and working together in cooperation. Anti-pollution laws, for instance, limit peoples' freedom to dispose of waste as they please to promote the common good of a clean environment and resultant health benefits.
Laws provide for the peaceful resolution of disputes. Without legal processes for settling differences, people would act against one another in aggression. Laws create peaceful processes for conflict resolution through the court system.
Laws and rules help people develop good behavior. Often, people initially obey rules due to fear of punishment. However, consistent behavior causes them to internalize lawful conduct and eventually do it, even when they are not being watched.