There's little reason for it except that the hotel industry has greased enough palms to get a law passed in their favour.
Housing shortage is one good reason, safety is another. Plus it's a nuisance for the neighbours to have short stay guests partying all night and making a fucking pigsty of the building.
Most of these laws are on the books to make a city a nicer place to live. Sites like AirBnB and Uber are not about sharing but about selfish parasitic behaviour. I hope cities across the world will follow New York's example on this one.