About 1200 B.C. the Babylonian King Hammurabi inscribed a code of laws on a tall stele of black basalt. This wasn't the first document of its type but it is widely accepted as one of the most comprehensive, broad and intellectual of its type. Neither was The Code of Hammurabi the first example of law in this earliest of civilisations. Mesopotamia had already existed as a culture (if not a unified nation) for 1500 years and relied heavily on agriculture, trade and commerce. Clearly some sort of 'law' existed during this time but it was the invention of writing in about 2800 B.C. that enabled ideas of organisation and civilisation to be recorded.
How much detail the GM decides to go into largely depends on the type of game he is trying to run and what sort of society he has created. Law's reflect a societies 'norms' and define what is right and what is wrong based on those norms. The laws of an evil culture like those of Dark Elves would be different from a benign culture. Similarly the priorities - and therefore the rules - of a tribal society would necessarily be different from those of a structured and civilised state.
Some Laws however are universal and essential to the smooth running of any society, regardless of its socio-political belief system.
- Do not kill people
- Do not steal another's property
- Do not damage or destroy another's property
- Do not covet a neighbours property/wife
- Do not challenge the rule of authority
- Do not lie or bare false witness
These probably sound familiar as all of them are included in the ten commandments and other faith based laws. Without these basic rules society cannot hold itself together and function effectively. Moreover they form the building blocks for all the subsequent refinements and subcategories of law that we know today.
Punishment for breaking laws will again vary with the culture involved and the degree of importance that each law holds within that society. In most medieval and ancient societies punishment generally took the form of some kind of retributive action that reflected the crime committed. Therefore murder incurred a death penalty and stealing resulted in physical justice (decapitation of a hand for example). Unfortunately history also teaches us that in less developed societies social status & personal wealth greatly influence the punishment decreed.
There is plenty of material on the Internet that the GM can use to create a basic set of laws for their campaign world. Whatever you decide to use it will enhance the realism of your campaign setting and may even create some exciting roleplaying encounters along the way.
I know that in my game worlds I am hit and miss with this but try to give it some basic framework. Also, U try not ot use the sweeping choice that all justice is handled along medieval models of "Might Makes Right", "Trial By Ordeal" and other tropes.
A couple of examples from two of my settings -
1) In The Valley of Baryn, the central setting of my "Homeland" campaign, the society is a widely spread collection of communities without a formal system of lords and such. Justice is administered on a community by community basis but along common ethnic and cultural lines. This means that two communities might use similar approaches but differing degrees of severity. Only the largest of the communities has anything resembling a sheriff or formal city guard.
2)In Ravania, one of the greater empires in my oldest campaign world, there are several levels of authority and justice spanning across cultural, social, and even class lines. There is an older order of rangers that operate like marshals, local authority based on noble rights, and then there are village traditions and superstitions. There is also a church athority as well as a new brand of legal justice being brought by civil investigators (think modern police/detectives). This makes Ravania a muddy quagmire of cross-cultural misunderstandings and athority struggles.