1) Mutual funds get hit with a lot more taxable events (any rebalance or dividend), and only a small fraction of that can be shielded.
2) Even if you could borrow to invest, stocks fluctuate a lot more and you would be subject to margin calls.
3) You are implicitly paying maintenance/insurance costs as a renter, true, but only as a renter do you benefit from division of labor and tax-deductibility of such expenses.
4) For the specific time history: It would have been difficult in the 70s to buy something like an S&P index mutual fund; Vanguard started then but you're unlikely to have heard of them. Then again, you wouldn't be borrowing at 5% either!
So technically you're using low-cost mortgage lending (2.15% rates are possible) to invest and get 5-7% returns on average, plus writing off the interest payments.
Which is subject to depreciation recapture upon sale, so it's more of an immediate cashflow benefit than a long-term structural benefit. (It can also be seen as a form of "hand-out" to renters, but it's unpopular to complain about that, so few people do as compared to those who object to mortgage interest deduction.)
Of course you can [0], and it's even cheaper than mortgage interest (because it's much easier to margin call a stock a portfolio than a house!).
Also, do you think property taxes and maintenance expenses aren't passed on to renters in the form of higher rent?