I do agree that buying a personal residence is not a good investment (neither is renting, of course). These are liabilities that need to be minimized. It depends on your own situation what is best for you and your family.
investment property can be quite lucrative. If you learn how to invest right and manage well (typically through a property manager), you can reliably beat the index funds most years. I own seven residential and one commercial property and only spend a few hours per month keeping the books most months. This can be done as a side hustle if you have the energy.
There is nothing wrong with index investing for people who don't want to or can't get a financial education, as investing in things you don't understand is a sure way to lose your money.
But for those who want more involvement and higher returns than index investing alone can provide, buying real estate can be a good option. So can learning and applying value investing in the stock market or selling options, etc. It all depends on the investor and what interests them and what they are good at.