The home you live in is a terrible investment. Real estate is only really an investment if you're generating revenue by renting it out.
For example, say you buy a $200k house at 4% interest. You will pay $144k total in interest over a 30 year mortgage. Assume your home value appreciates by 4% a year (which is around average) and you put 1% of the value of the home back into the home in improvements every year (on the low side, but reasonable).
After 30 years, you have a paid off home worth $625k. You've paid:
Principle: $200k
Interest: $144k
Upkeep: $112k
Total: $456k
You make a "profit" of $169k if you were to sell at that point (this ignore realtors fees, property taxes, insurance, cash out refis or home equity loans, etc for simplification). That's about a 37% return on your investment, which over 30 years is not great (in reality it would be less due to the above costs removed for simplicity).
To compare, I could put $300 a month into an S&P 500 index fund (total investment of $108k), get below average returns of 7%, and have $366k after 30 years. That's 240% return over 30 years.
Yes, the math is simplified and not exact and ignores several factors, but you can see how the home you live in is actually not a great investment. But your home is more than just an investment, it's your home. That's why we're willing to put up with poor returns on it because it's more than just a money generating thing. Just don't delude yourself into thinking it's a great investment. For most people, who are not diligent investors, it may be the only way they generate any wealth, so it that regard, it is a good thing to buy a home. But a diligent investor in the stock market should be able to get much, much higher returns than their home. None of this mentions that almost no one stays in their home for 30 years and is moving every 5 years or so and is playing realtor and closing fees that eat into their profits.
Rental properties are a completely different story. They are usually on par with stock investing if done right.