Most people gamble to make profit. Some do it for quick gains, other do it for the adrenaline rush they get. But in the end, everyone has the same goal. To end up with profit. There are some people that gambles for pure fun. They enjoy making profit. Hence, in video games you will see some of them offering the option to gamble with virtual currency or in game currency. People can have fun playing those without risking their real bank.
As an old example, Fallout New Vegas has an in-built game called Caravans, but you can play blackjack, roulette, etc... Newer games that are free to play or cheap to play offer lotteries that award prices such as unique or rare in-game items...
If you are talking about those loot boxes, then yeah. They are form of pure gambling and some countries are trying to stop those sort of gambling.
There is currently quite an effort on using these techniques in games that should not be about gambling or chances playing and some people may find undesirable. Is this going too far? What type of effect may this game on underaged players?
Most of those games are age restricted. So I doubt any of those underaged players get exposed to those gambling contents.