Loot boxes are generally not considered gambling because you don't wager anything and don't win money. They are very much like a kids version of gambling though!
Epic allowed you to purchase loot boxes and get a random chance to get the thing you wanted as a result.
If it's something you can't pay for and it's intended to be a part of the way the game works, it's not intended to push you into spending money or anything like that, that's fine. Loot boxes are fun at the end of the day. That's not what this was though, this was gambling.
It's slimy, but per the legal definition, it isn't gambling.
Should it be illegal? personally, I think if it's targetted at children then yes.