Writing a code of conduct into law establishes consistent guidelines for people to follow. Laws are drafted with any of five major principles in mind, according to About.com. The first two principles are to prevent harm to the self and others; the other three are morality, donation and statism.
Laws passed under the harm principle are usually straightforward and easy to connect to the common good, notes About.com. Murder is a form of harm as are larceny and vandalism. Prohibiting these with the law allows society to function smoothly and with justice.
The second principle can be called "parental." Parental laws usually deal with victimless crimes, such as drug abuse or truancy. Such laws are, theoretically, for the benefit of those who break them, explains About.com.
Moral laws codify some segment of society's ideas about proper behavior, according to About.com. Laws prohibiting same-sex marriage fall under this rubric.
"Donation" laws promote the interests of agencies, businesses or populations with giveaways or other benefits, states About.com. Tax breaks and local grants often fall into this category.
Some laws exist for statist reasons, according to About.com. The government usually passes such laws to secure and promote the government's power. Laws banning sedition are an example of laws passed to protect the state.