It has nothing to do with deciding whether to buy a home or be homeless and put the money in the stock market instead.
Obviously being homeless isn't a good idea, and I'm a little surprised the OP is being interpreted as promoting being homeless.
This is purely about an investment decision - if you had to invest in a diversified portfolio of residential homes or a diversified portfolio of stocks, which would yield the higher expected return? That's the question being asked an answered.
Whether you buy or rent or are homeless is a totally different question.