The average person with no knowledge will do better investing in equities (index funds).
The person who takes time to learn real estate will do much better in real estate, IMO.
The stock market is such an efficient market, combined with the speed (electronic transactions) that it's hard even for someone knowledgeable to take advantage and gain an "edge." Whereas in real estate, you can find deals - undervalued properties. Hard to find a "deal" on a stock, and purchase it under market.
But buying without knowledge can kill you, especially if using leverage. This is true of both investment types, but look at what happened to many who bought extra rental properties in the mid-2000s: foreclosures galore.
I plan on having a lot of real estate and a decent amount of equities, and I expect the former to do much better overall, but the latter to provide a nice secondary source of income, much more diversity, and much less work.
tl;dr: A home, purchased randomly, in a random market, likely will vastly underperform the S&P. A carefully selected home (or ten) in a strategically chosen market will beat the S&P, IMO.