In 1895 New York (then Manhattan and part of what is now the Bronx — the rest of the outer boroughs didn’t join the metropolis until ’98) horse-drawn and other vehicles could drive in any direction, on any street, at any speed (the actual speed limit of 5 mph being ignored). There were no stoplights or even stop signs. Gamblers and prostitutes (more than 30,000 of the latter) were brazen. Children scampered into bars to get their parents’ “growler” jugs refilled with beer. You could even smoke tobacco in a public park.

Into this arena of decadence stepped a disgusted 5-foot-8 patrician with the body of a lion tamer and the morals of a schoolmarm: Teddy Roosevelt.

Roosevelt’s career, as Richard Zacks writes in his vivid and entertaining book “Island of Vice,” had flatlined. Having lost his 1886 race to become mayor of New York, he drifted off to Washington to be a drudge in the Civil Service Commission for six years. But after the candidate from the corrupt Democratic party machine known as Tammany Hall lost the 1894 mayor’s race, TR was invited back to serve as one of four New York City police commissioners. Vowing to clean up the city, Roosevelt stormed back.

Battle was joined. On one side were well-off Protestants, like the Roosevelts, who had been the ruling class in New York for generations. On the other were the bustling, swarming hordes of the poor, mainly immigrants and Catholics, whose housing was so crammed they were forced to sleep in shifts.

Saloons were technically forbidden to open on Sunday, but bar owners simply tipped their local cop or pol to stay open. Since working people only had one day off, Sunday was the biggest drinking day.

Weeks after taking office, TR decreed bars must close at 12:01 Saturday night, and when the workers and their media (most notably Joseph Pulitzer’s World, which then had 50 times the circulation of The New York Times) raised a fuss, he said he was merely enforcing the law. Reporters discovered that all sorts of crazy laws were on the books. Upon further scrutiny, even flavored soda could not legally be sold on Sundays. TR’s response: Crack down on that, too! There were also unenforced laws against cursing, flying a kite south of 14th Street and keeping a deck of playing cards in a college.

Roosevelt was rebuked in local elections a few months after he made Sunday go dry, but even though virtually every newspaper was against him (New Yorkers prefer to be “crazy and reckless” not “crazy and religious,” said Town Topics), he didn’t let up. He had compared his opponents to “lynchers and white-cappers” — meaning the Ku Klux Klan — who claimed “popular sentiment” as justification for their murders.

Cops started enforcing more absurd laws, for instance arresting anyone who sold flowers on Sundays. Shoe-shine stands, someone discovered, weren’t licensed, so the police started threatening to arrest bootblacks, too. The (Italians) who held these jobs thought the (Irish) cops were joking. “The police belong to a humorous race,” wrote one shoeshiners’ advocate.

TR’s story is a familiar parable about what happens when politicians attempt to heal diseased souls by prosecuting victimless crimes. And his motives weren’t as pure as advertised. Like Mayor Bloomberg, a reformed ex-smoker with an almost evangelical anti-smoking fervor, he took vice too personally. His brother Elliott had died of causes related to his alcoholism. Attacking the bars also had partisan implications: Saloons were meeting places and fund raisers for the Democratic machine the Republican TR opposed.

Roosevelt did the city a tremendous service by cracking down on crimes that hurt everyone — such as lazy and corrupt policing. He drove many blackmailers off the force, from the top (the head cop had pocketed $350,000 in graft — many millions today) down.

But TR’s mistake was to admit no distinction between crimes against the public and crimes against morality. “He slays a hippopotamus or cracks a flea with the same overwhelming ardor,” noted The Washington Post.

In one ridiculous case, a teen named Lizzie Schauer asking for directions to her uncle’s apartment at 16 E. First St. was picked up. She protested that walking on the street is not the same as streetwalking, and the case wound up with doctors peering into her genitals to determine whether or not she was a virgin. (They ruled that she was, and she was freed.) When the state starts to peer into souls, you never know where it’s going to wind up.

Roosevelt annoyed so many people that he ran afoul of his own party, which started a campaign to replace him and the rest of the Police Board. The bars figured out how to reopen on Sundays by restyling themselves “hotels” (even though many rented no rooms). The situation was, Zacks writes, “a Mad Hatter’s tea party where a sloppily written law aimed at repression would lead to wondrous new freedoms and cocktails for all, 24 hours a day, seven days a week.”

Gotham was a bronco the Rough Rider couldn’t break, and he left after less than two years, long after “it became increasingly clear,” writes Zacks, “that Roosevelt was far more popular out of town than in it.”

Teddy would never be mayor, instead accepting (in a period of less than three years beginning in 1898) the lesser jobs of governor, vice president and president.