Investment and gambling are both probability games. There’s no guarantee in either one that you will win.
The difference is, that the probability of winning is very high for long-term investment and very low for gambling. In two of the extreme cases, a 30+ year well diversified investment portfolio has a 99%+ chance of winning big, while the Supper Lotto has a 99.9999999% chance of losing completely. In another word, it’ll be a surprise to lose a long-term investment, and it’ll be a big surprise to win a lottery.
While it’s not possible to get rid of all the investment risks, the probability of winning is under everyone’s control.