The cost of capital is part of the cost of buying.
The reason mortgage "looks" cheap, when only counting cashflow, is that they haven't considered the cost of capital.
If you add up all costs of a mortgage - including cost of capital (as well as maintenance etc) - it isn't cheaper than renting, and on average, i reckon it would be slightly more expensive, and at best it's neutral.
Lots of people don't have the downpayment or upfront legal fees available. They cannot buy.