BUt the comparison to the S&P isn't entirely apples to apples. You don't HAVE to invest. You can if you want, and it makes sense to, but you won't freeze if you don't, you won't die if you don't, your shit won't be stolen if you don't. You DO, reasonably, need a place to live; to keep you warm and dry, safe and protect whatever it is you're carrying through this mortal coil. The RENT you pay is a negative investment. It's not doing ANYTHING for you, economically, and in fact, you're probably OVERPAYING for your space, once you factor in no equity, first/last/security deposit, and any profit your landlord is making.
In other words, unless you live for free, or in a cardboard box (also free), the money from your HOME isn't likely going directly into a S&P account. And by owning, you get the equity you build, AND you get any tax write-offs you might get from carrying the mortgage.