Law exists primarily to defend property. In medieval world, the primary concern was how real estate, often defined by a title, was maintained and passed on by the nobility. This was dramatically extended by the American Revolution when fundamental rights were determined to be something that everyone possessed. The idea of intellectual property, which are rights based on inventions of the mind, was also carefully codified. The US Patent and Trademark office was opened up to define just what property would be protected by law.
From there, it eventually starts to get a bit strange.