In the late 1800s, the city hired drainage engineer George E. Waring Jr., who had worked on Central Park, to start cleaning things up. He pushed for new laws forcing owners to stable horses overnight (instead of leaving them in the streets) and mobilized crews to gather manure and horse corpses to be sold for fertilizer and glue, respectively. What they couldn’t sell was transported and dumped instead.
And by the early 1900s, other factors were in motion — electric streetcars and internal combustion vehicles were gaining traction. Rising land pricing (for stables and farmland) coupled with higher food costs increasingly made these new options more economical, too.