Gambling involves the opportunity to win something that actually exists. The fundamental issue with loot boxes is your gambling for code that can't be sold, traded, or preserved past the lifetime of the game.
It's a disgusting practice that preys upon people's psychological reward centers and has been normalized by our obsessive consumption. It should absolutely be illegal.