The main purpose of Hammurabi's Code was to establish a comprehensive set of laws that would govern the society of ancient Babylon. Created around 1754 BCE under the rule of King Hammurabi, the code aimed to promote justice and order by providing clear and consistent legal guidelines for various aspects of life, including trade, property rights, family relations, and civil rights.
Hammurabi's Code also served to reinforce the king's authority and duty to uphold justice, emphasizing the principle that the law applied to all members of society, from the highest to the lowest. The code's "eye for an eye" principle sought to ensure that punishment was proportionate to the offense, helping to deter wrongdoing and maintain social order. Overall, the code was a significant step in the development of legal systems and the rule of law in human civilization.