Landowners and merchants hired private police to watch over their holdings. Over time, they convinced locals that it would be in the public good if the guards they hired were paid for by everyone.
In the 1850s, in Boston, they formalized this arrangement into the first police department in the country. (There's an interesting history here around the oppression and then incorporation of Boston's Irish population by the police force.)
Edit: Curious about the downvotes -- this is a review of US history.
The way that this dynamic extends into the busing crisis and the infamous racism of Boston sports fans should be obvious.