I question your "almost always".
If I buy a home, it's a depreciating asset. That is, I buy a home (via mortgage) for $300,000, and at the end of the mortgage, it's only worth $200,000. So I've paid $300K for an asset that's only worth $200K. But if I rented, at the end of the same time period, I have an asset worth $0, and still have to pay to live somewhere.
But of course it's not that simple. I can often rent for less than I can buy; I can invest the difference. If I don't live in the same house until I pay off the mortgage, I don't wind up with a place to live for free. If I downsize, I can wind up with a place to live for free and a chunk of cash. And so on.
Let's take one specific example. Suppose I have little cash. I could borrow $300K and buy a house. At the end of 30 years, I have a house. I've paid, what, $2000/month in payments. At the end of the deal, I have an asset worth $200K, in which I also can live for free (but I can't do both - I can get the $200K, or I can live in it for free). If I want the same deal putting the money into a mutual fund, I probably can't get it, because nobody's going to lend me $300K to invest in a mutual fund. The deal I can get is to rent for $1000/month, which gives me $1000/month to invest. At the end of the same amount of time, I have nothing to show for the $1000/month in rent except having not been homeless. For the $1000/month I've invested, I have... well, it's hard to say. What's your best guess about the rate of return of the mutual fund, and what's your variance around that best guess?