I used to be instinctively against stuff like this, but I actually think it’s pretty reasonable now. People outside of a given city/country/etc. have no inherent right to participate in that place. Local residents should only allow outsiders to participate if they derive some benefit from it. Now, that said, there may be unintended consequences to eliminating foreign purchases of real estate.
Vancouver, BC passed something like this a few years ago - it’s a 20% tax on all non-resident home purchases. It has actually stopped house prices from rising so fast, but there are still a bunch of empty homes.
Sounds like the tax is too low then. If the vacancy tax is high enough, landlords will have no problems finding a tenant. This is vancouver and sf we are talking about, snap your fingers and you will find a tenant if the price is right. Too many greedy people.