Quoting myself from a previous answer to a similar question:
London's Bow Street Runners, founded in 1749, are regarded as the foundation of modern police. They were a formalization of the existing practice of 'thief-takers' - people who solved crimes for a fee.
Then, in 1829, in response to the growth of London (and the growing difficulty in keeping the peace) the Metropolitan Police Service was established. This was the first professional, modern police force that was built as a civilian service, with civilian oversight, and accountability to the people.
Prior to this, 'police' were basically only for keeping the peace in towns and cities, and not catching or prosecuting criminals. For example, the duties of Lieutenant General of Police, the foundation of the Paris police, were described as "ensuring the peace and quiet of the public and of private individuals, purging the city of what may cause disturbances, procuring abundance, and having each and everyone live according to their station and their duties".
As for the modern legal system - as opposed to the policing system - that isn't a topic I am confident in answering, so I will leave it to someone else.