Was there a document predating the ten commandments which had the same purpose?

by 0blation
White___Velvet

Can I ask you to clarify what you mean by "purpose" here?

For instance, does the code need to be purported to have been dictated by a deity? Or does it simply need to be a set of rules governing a peoples behavior?

Pretty far outside my area of interest, but I do remember the code of Hammurabi from my world history class in undergrad, which you may find interesting depending on what specifically you are looking for.