When you compare it, it seems investing is more legal term, more professional, more okay than gambling. Investing is a way better but they are both risky. But I think it's safer in investing than gambling because in gambling you will just depend on your luck. If you lose in gambling you will lose everything. It will affect your life and it is addicted which leads you into evil doings.
You are right, Investing is more better than gambling. They both risky, but gambling is more risky, because when you lose, it's mean lose, but when we talk about investing in bitcoin for exemple or in some cryptocurrencies, the probability of lossing is high, because as we know that cryptocurrencies prices always increase each period of time, but there is other risky domain of investing, for exemple like cloud mining sites.
So we should always be careful when we put our money, and thinking a lot about that.