Capitalism is somewhat of a gamble, but it’s better than socialism where the majority are guaranteed to have nothing.
You could have capitalism without a stock market.