It increases the demand for real estate, which increases the price of real estate. This benefits those who own real estate. Many residents own real estate, so they do benefit from the policy.
I’ll actually argue that it artificially inflates the price beyond the means of those who do not own yet and even those who own but are priced out of upgrading to a better home/location, by bringing in investment money from outside.
Housing is a necessity, and should be limited to residents, IMHO at least.
Some need a house to live in, others want estate to invest in.
I say we should prioritize housing: it is a basic necessity with few alternatives, if any. If you want to invest your money, (1) it means you already have money so you aren't struggling and (2) you can invest elsewhere that isn't as harmful for others.
How does someone become a resident if they can’t buy a place to live? This is a chicken and egg problem that is similar to banning foreign purchases entirely.
What benefit does it provide to a country or its residents if home purchase is opened to foreign residents?