The municipality tried to raise taxes, but it isn't working. The owners' pockets are too deep and the apartments are bought for social reasons, not economic ones. Whatever the city charges, the wealthy will pay.
There isn't an easy solution. If the law were to require occupancy, then the law would penalize honest landlords who do seek to rent out their apartments and deal with frictional vacancy as an investment risk. If their apartments were to be "raided" during frictional vacancy, what then? Should law enforcement accept that the vacancy was frictional and not long-term? How is law support supposed to tell the difference? If the law is too hostile to honest landlords, then they'll sell their investments, and the cost of rent will rise, which is regressive.
The only real solution I can think of is require mixed-use zoning and fine developers for failing to lease the retail space. If the developers sell too many apartments to ghost owners, then the retail won't get foot traffic, so the retail space will fail to lease, causing the developer to be fined, and incentivizing the developer to ensure that he sells to long-term occupants instead of ghost owners.