One thing to not forget is the amount of leverage provided for you in the housing market is disproportionate compared to the leverage you would get in stocks (20% down is 5x leverage, and there are some options to get in on a house with even less than that).
If you look at the real rate of return on everything (paper from 2017, analyzing the period between 1870 and 2015 in several developed countries), they claim the return on property is around 8% per year, which is comparable to stocks but with a lower variance.
A caveat though is that housing outperformed equity slightly 1870-1950, and equity has outperformed 1950-today. Housing is also a very locale-specific thing, since there is no global private 'housing' market you can invest in.
But I think almost everyone who doesn't have an interest in doing the grunt work of real estate investing would be better served sticking their money in an index fund ETF rather than real estate. It's drastically less work, less worry. Extremely low cost broad market index funds and ETFs are relatively new too, I'd be interested in seeing an analysis of performance after they went mainstream.
Land prices in very, very few areas have increased sufficiently to match a risk adjusted return (or even the nominal return) of a broad market index fund, such as VOO or VTI. Especially considering the liabilities and ongoing maintenance costs with owning housing structures.
The labor adjusted return is far better too, you spend minutes and a few clicks investing in an index fund, versus hours and days on real estate.