Law is a set of rules that a society or government develops to deal with crime and business agreements, and to regulate social relationships. It can also refer to the profession of lawyers or judges.
Law aims to ensure a minimum level of justice and protect individual rights, but it does not necessarily reflect the values of any particular society or group. For example, a legal system might punish people for destroying property, but it might not punish them for being gay or having cancer. It is also possible for laws to have a religious basis, such as the sharia or canon law of some church communities.
Even in a well-ordered society, people sometimes disagree and conflicts arise. Law enables people to resolve these disputes peacefully. For instance, if two people claim ownership of the same piece of land, they can use a court to decide which of them owns it. Similarly, a conflict over a debt can be settled by going to court rather than fighting over it.
In general, the more detailed a legal system is, the more it tends to be. More detailed systems are often developed by professionals, as they have the time and resources to think about how best to solve problems. For example, Roman law was heavily influenced by Greek philosophy and underwent major codification during the later parts of the Roman Empire by professional jurists. In contrast, medieval law was largely based on custom and case law.