That is an interesting question.
Written laws are important for several reasons. Written laws provide a shared reference. Once a law is written down, there is an objective record of what the law is. That means if you can read the law, or can get someone to read the law to you, you can use it. On the most basic level, you can consult it directly, so you know what to do and not do.
Laws existed before writing, but they were held in memory. This meant you had to go to the people who knew the law (usually the wise elders of a society) and ask them what the law was. This means the oral transmission of culture is disrupted, these laws can mutate or be lost.
Written law also allowed a society to grow beyond a certain size. To use the example from above, in an oral culture you either have to be directly in the presence of the people who know the law, or have the law passed on to you by word of mouth. That puts a practical limit on the size of a society. Written laws allows continuity across space. Imagine trying to govern a nation like the United States using only laws passed on through word of mouth. That would be next to impossible.
Historically, writing laws down allowed a kind of democratization of power. You can see this in ancient Rome, when the common or plebeian class pushed for a change from an oral legal tradition, and for laws to be written down.
If we do not have a written code of law, the rules can become completely arbitrary, whatever a particular ruler says they are, we have no means of knowing what our rights and duties are, and the government has no means of enforcement.
Imagine a world in which laws were not written. You could be driving down the road one day going 65 mph. The next day, the police might stop you as you go the same speed, explaining that you had just broken the law. But, you say, the speed limit is 65 mph. The officer could say the governor had just changed his mind. Today the speed limit is 40 mph. There would be nothing you could do about that, with nothing in writing you could point to. Without written laws, you might be sentenced to three years for a crime one day and sentenced to death for the same crime on another day. You are now responsible for the health and welfare of your children. That is your duty under the law. If that law is not in writing, how will the state ever enforce it?
To have an orderly society, laws must be written so that we can depend upon them to guide our behavior every day, so we are protected from arbitrary changes, and so that the state can intervene if need be to enforce its laws.