Nine times out of ten, I'd say stocks for the long run. But I think at today's mortgage rates, it's pretty compelling. Let me just run through a toy example.
Say, you're buying a $500 thousand property with 20% down at a 3% mortgage rate. You're paying $1500 a month on your mortgage, and generously round it up to $2500 for taxes, insurance, HOA, and maintenance. There are very few places in America, where a half million dollar property would rent for less than $2000/month. Let's generously round that down to $1500/month for vacancies, turnover, evictions, etc. (And if it's your primary residence, you still "collect rent" by avoiding the expenditure of renting from someone else).
On the face of it, this seems like a terrible deal. Cashflow wise, you're losing $12 thousand a year. However take a closer look at that mortgage payment. Starting from day one, $10k/year is going to principal pay down, which directly increases home equity. Another tailwind: price appreciation. Historically real estate tends to increase at the rate of inflation (currently forecast at 2.3% in the TIPs market). That's another $11.5k/year in home equity appreciation. (This assumes a base case, zero appreciation above inflation. It doesn't even scratch the surface of our current housing shortage and the fact that houses have been appreciating 2-3% above inflation.)
In terms of accounting profits, you're actually making $9.5k/year. It's true you're flushing cash down the toilet, but you're building up home equity to counter it. Then in 5-10 years, you get your money out by either flipping for a big profit, or doing a cash-out refi.
The ROE on that $80,000 down payment is 11.9% annualized. Historically the stock market has averaged 8-10%. And today's CAPE ratios are near historical highs, which would suggest lower long-term returns. This doesn't even get into the tax advantages on the real estate.
All in all, real estate looks pretty compelling from an investment standpoint today. Now, I'm normally an efficient markets guy, so I don't say this lightly. But I believe the major driver is the lopsided nature of the cashflow vs. equity division of real estate returns in a near zero rate environment.
The vast majority of real estate investors think in pure cash flow terms. The idea of buying a negative cash flow property seems ludicrous. So, right now I think the market's leaving a ton of attractive real estate investments underpriced.