Complex societies also have complex relationship and interactions which need to be controlled with a more definite sense of justice and order. Codes exists to regulate interpersonal and inter group relations with an clera mandated set of rules.
In small, simple societies, everyone knows everybody else. Moreover, people are often related to each other by bonds of blood. Therefore, conflict does not arise as easily and it is dealt with in a swift way. However, as societies grow, conflict becomes more complex. Moreover, this often includes strangers who might have very different opinions about the best way to act. Therefore, a code of law ensures that these situations are solved in a fair and peaceful way.