The main purpose of Hammurabi code was to

establish order and justice in society.

The main purpose of the Hammurabi Code was to establish a comprehensive and unified set of laws to govern the Babylonian society during the reign of King Hammurabi in ancient Mesopotamia. It served as a legal and social framework, aiming to provide justice, maintain order, and regulate various aspects of Babylonian life. The code was intended to be fair and equitable, ensuring that the rights of individuals were protected and disputes were resolved in a consistent manner.

The main purpose of Hammurabi's Code was to establish a set of laws to govern the Babylonian society during the reign of King Hammurabi, who ruled from 1792 to 1750 BCE. This code is one of the earliest examples of written laws in human history. It served several purposes, including:

1. Promoting justice: Hammurabi wanted to establish a fair and just society. The code aimed to provide guidelines for resolving disputes and ensuring that punishments were proportionate to the crimes committed.

2. Regulating society: The code sought to maintain social order and stability by governing various aspects of daily life, such as marriage, property rights, trade, and labor. It aimed to establish rules and standards that governed the behavior of individuals and groups.

3. Consolidating royal power: Hammurabi used the code to emphasize his authority as the ruler. By claiming that the laws were divinely inspired, he presented himself as a just and wise king. This helped to centralize his power and maintain control over a vast empire.

To understand the main purpose of Hammurabi's Code, one can study historical documents and texts from the time of Hammurabi's reign, such as the epilogue found on the stele (stone pillar) containing the code. Additionally, scholars and historians have analyzed the code's contents, historical context, and cultural implications to provide insights into its purposes.