Answer
The Code of Hammurabi were enacted in Babylonia circa 1792 to 1750 B.C.E. It is one of the most ancient legal codes written in human history. All Babylonian citizens ought to abide to this set of rules, including the king. Therefore, it limited the king's power and prevented him to impose his will, it was against the law.
Explanation
The Code of Hammurabi is was King Hammurabi’s attempt to set a clear set of rules to all people living in a complex, large and ever-growing empire. The code intended to establish clear rules that govern people behaviour, what was considered unlawful and the punishment a citizen would expect when breaking the law. For instance, it forbidden slander, perjury, fraud, theft and adultery. It also created a legal framework for trade, slavery, divorce, liability and the relationship between workers and landowners.
The code was not necessarily fair. It was especially harsh on lower classes and women, making the laws unequal. For instance, the punishments received by higher classes when they had a dispute were far lenient than the ones imposed on lower classes.
However, and in spite this unfairness, the code limited the capacity of a single ruler to impose his/her own will over other people. The clear set of rules prevented the king from using subjective appraisals to judge singular cases. All people would measure with the same rules, and these could not change from situation to situation.