The most complex of Mesopotamia's institutions was probably Hammurabi's written legal code, the first in recorded history. In addition to this, several other Mesopotamian institutions, from a government bureaucracy to a system of welfare designed to alleviate famine, were important in the history of civilization.
Mesopotamia was among the first places where humans gathered to live in large cities. This led to a number of new problems, such as how to provide food to everyone, how to defend against enemies, and how to determine who gives the orders. In small villages, everyone grew crops or fished, everyone fought marauders and the leader was chosen more or less democratically or by heredity. In cities, it proved more effective to have a king who ran a bureaucracy of skilled administrators. With different cultures mingling in these growing cities, cultural norms were displaced or formalized by legal codes that everyone could understand and abide by. These codes were soon written down. Legal codes led to a court system to enforce them, and to a police force to ensure the court's rulings were enforced.
The government in Mesopotamia quickly found more problems that needed redress. Flooding led to a public works program in which citizens donated work to build dikes. Soon the government officials realized that it would be more efficient to pay specialists to build these and similar structures, so instead of requiring labor, they created a system of taxation that also enriched the king, tax collectors and priests. A larger populace made an educational system necessary, and educated citizens wanted libraries. As Mesopotamian cities grew in size, a complex civilization developed around them.