This ascribes morality to an amoral thing like population growth and markets. Buying anything is an investment. That’s what investment means - you take resources and invest them. The growth in value of an investment in a market is an artifact of supply and demand. Not all homes rise in value, some decline, and many are fairly stable over time. Likewise rent doesn’t rise steadily everywhere.
The absurdity of the story here is reflected in the person with the rent vs buy calculator trying to see which decision makes the most sense, then feeling a moral outrage that in order to make money the price of the house has to go up. This is like being morally outraged that X-Y is only positive if X is greater than Y. You certainly can be, but what’s the point and why on earth would you talk about that publicly?
By the way, home prices are most easily thought of as a proxy for rent utility. If you can buy a house on debt and rent it for more than the principal risk and debt cost then you’ve got an arbitrage opportunity and prices will go up. Likewise if you can’t and you’ll lose money prices will go down because prices are too high. So complaining about house prices and rent as orthogonal ignores that they’re intertwined.
Mark Twain gave the advice to invest in real estate, they’re not making any more of it. Ignoring that you should never take investing advice from Mark Twain, there’s truth to it. Lack of affordability has to do with scarcity - if everyone is moving to San Francisco and expecting to be able to buy a beautiful Victorian in the Castro, expect the prices and rents to be sky high as there’s only so many and there will never be more than there was effectively 50 years ago. There’s nothing immoral about this. It might feel unfair in some “the universe owes me a beautiful life” way, but it’s actually not unfair. It might feel unfair that someone working for the city who moved into the Castro in 1970 got a great deal on a beautiful house while you live in a SRO in the Tendergroin with 15 roommates working as a senior principal engineer at google, but it’s actually not. It’s just the way things are. If you don’t like it, it’s not the city workers fault for being a nimby that you can’t afford their house, or that the city they live in attracted so many wealthy people and the value of their house exploded.
There simply no morality at play here. There’s no way not make ownership of property not an investment. There’s no entitlement to affordable housing. We can work to make more house available so more people can afford it, but we also probably can’t ensure everyone on earth can move to San Francisco and have a nice house in Noe Valley.