buying a house to live is not an investment, and i should think that people ought not to treat it as such. Buying a house gives you stability and security for shelter. It's quite possible that renting is cheaper, but you also can't do certain things while renting - such as small renovations (some places don't even let you nail a painting on to the wall).
Investments in real estate is a different ballgame to buying your home.
I'm happier living in a house than an apartment but my house is a place to live, and an item of value, but not an investment I expect to make profit from.
(according to random site on the internet, it's a little below inflation: https://www.in2013dollars.com/2002-dollars-in-2018?amount=30... )
That said, buying a house is basically buying an index linked annuity that covers your rent on a property you have to maintain. So it is an investment, albeit one tied up with a lot of other baggage.
You know the same thing applies to stocks and shares. And in fact stocks and shares have risen more historically [1]
Shares also have liquidity, you can easily sell them in part or whole. You can diversify. One incident could easily destroy a house, if it destroys your well diversified stock investments you've probably got other problems.
So agreed the stock market is the better investment, but as we can't see the future, both are based on past performance. Yes there are headwinds, there always are, I can think of many many reasons why stocks could fall, that doesn't really change what has happened historically though.
Of course the beauty of investing is that if you disagree you can put your money where your mouth is :)
[1] https://www.investopedia.com/ask/answers/052015/which-has-pe...