Real estate prices swing around, wax and wane, just like the stock market does. It's just that there is no real estate price ticker.
Investing in the S&P 500 is even less effort. The last time I bought a house, I had to carefully read and sign about 50 pages of legal papers. Buying stocks is just pushing a button.
In places like the Bay Area, property values pretty much never go down in price, and the YoY relative increase is on par with that of index funds. Combine that with rental income, and you can very likely beat an index fund. Mortgages offer much more leverage than margin loans, which helps offset the upfront capital cost.