There was a time, long ago, when there were only 10 things that thou shalt not do.
That was fine for a few thousand years until a fellow named Hammurabi decided that 10 things weren't enough and came up with 282 laws that he codified based on decisions that he had made during his 42 year rule of Babylonia.
The intent was that everybody would know what their rights and obligations were.
Many of our modern laws have evolved from that body of law but, sad to say, some of Hammurabi's laws have not stood the test of time, but should have.
A man caught committing robbery was put to death.
A man whose negligence caused damage to another was sold into slavery and the money from the sale was given to the damaged party in compensation.
A person who committed fraud was made to pay ten times the loss to his victim.
One that I especially like is that a judge who reaches an incorrect decision gets fined and permanently removed from his position.
Time marched on and it became common for the rulers of the lands to make the laws that would insure their continued sovereignty. This was accomplished by writing the laws in arcane language understood only by the writers. This, of course, necessitated being able to teach the laws to their successors and resulted in the development of law schools where the practitioners were taught to dance around the fire and chant the arcane language of the law.
To keep the understanding of the law to a select few the teachers of the law charged a very high entry fee which the practitioners subsequently had to recover by charging high fees to their clients who had no choice but to pay or be bereft of legal representation.
That explains the complexity and cost of today's modern legal system.