Forget, for the moment, which will pay off most over the long term. Consider risk exposure.
You've said that you (hypothetically) have "little or no money": that's the deal-breaker. From a risk-management perspective, your investment portfolio would be better off diversified than with 90% of your assets in a house.
Consider also the nature of the risk which owning a house exposes you to: Housing prices are generally tied to the state of the economy. If the local economy crashes, not only could you lose your job, but you could lose a good part of the value of your house... and still owe a lot on your loan. (You also might not be able to move as easily if you found a new job somewhere else.)
You should almost certainly rent until you're more financially stable and could afford to pay the new mortgage for a year (or more) if you suddenly lost your job. Then you can worry more about maximizing your investments' rate of return.