People collectively can decide(and frequently do decide) that the values important to a town, a city or an entire state are more important than your right to buy and leave property empty. There are many places which either forbid owning property entirely if you are a foreign national and don't actually live there, or impose a heavy tax on such purchases. Vacancy tax is a thing too.
Basically if a city(and by that I mean people of the city and its representatives) don't want houses to be sitting around empty, there are laws that can be introduced to force people to either move in, rent or sell the place, or they can keep the place standing empty at a heavy financial penalty if they wish. Like I said earlier - your prerogative ends somewhere.