The problem is that over that long a period of time, inflation may have halved the purchasing power, meaning your gain is a paper one, you spent a lot of years fixing and maintaining the house, paying taxes and insurance, working on the yard, maybe did some remodeling, etc. If you'd instead invested in the stock market any surplus over renting, you often would have come out ahead.
Most people would find a way for that surplus to turn into lattes, vacations, new cars, and large TVs rather than into shares of VTSAX, so for them, homeownership is a good idea, not because it's a better investment than equities, but because it's a better savings vehicle than nothing.
I'm a homeowner and very happy about that fact for our family (for lifestyle reasons), but even in a steeply rising market (Cambridge, MA), my other investments have performed much, much better (even including the 2007/2008 crisis).