Long times ago, since humans gradually settled a little group to help each other survive in this world. In each group of human, there was a leader who controlled and managed the group. When the problem had occurred he or she must judged and make a decision to solve the problems. The times past, a little group had became a larger group, groups had become a society. In the other word, society is a big community which containing many groups of people. As you can see, people started to have complicated connection while they had connected across the group. A leader's decision was not enough to judge the people. So, they had to find out another strategy to fix this problem which seem likes more and more out of control.
Therefore, caused leader's decision cannot used as a standard in the society. They created a simple rules to control people's behavior by we did not have to wait for the wrong act to be done. This could be helpful to prevent people who was going to have a wrong doing. This simple rules might be different in other local area. It was depends on tradition or convention in each area for the comfort of the judge to adapt this rule in each case. They had also drafted the punishment in each case. Punishment was an essential element of the rules because people frightened the punishments, so they must realize to control their behavior to avoid the punishment. This is the beginning of the law.
Every decisions of the judge had record and reused for another case. The decision had become standard of the judge to justify the case. And this was the beginning of "Common Law" system.
When the time past, the simple rules still have a lot of gaps people learnt to use this gap to avoid sanction. So, the result was an obstacle in society when this simple rule cannot control people.
After that, administrators who govern the society started to draft the law which containing punishments, sanction and rules that covered all of the case.
So, the simple rules had been written in the code. When the judge had to justify each case, they can use this code instead of the simple rules which was unwritten law. This was the beginning of "Civil Law" system. The judge can makes the decision by refer to the articles in the code.