The difference between gambling and investing, though both involve elements of risk / chance and putting money out first for an uncertain reward, is that “investing” is the process of sharing risk that already exists. A farmer assumes risk that his crop may not come in due to weather problems or other vagaries of nature, for example, or even that it may come in, but it may be a bumper crop among all farmers in the region, which depresses the price he may receive for the crop. Either way, the risk he takes – or that others take on speculating on his success – is a participation in risk that exists “in real life”.
Gambling, on the other hand, is speculation in “created risk”. No one cares what numbers come up on a lotto ticket, for example, or the turn of a card or a throw of some dice, until money has been bet on what the outcome might be. There is zero risk on the lotto card, but the money bet on it creates the risk. Without the money bet, there is no meaningful risk.