The first known instance of a loot-box system is believed to be an item called "Gachapon ticket" which was introduced in the Japanese version of MapleStory, a side-scrolling MMORPG, in June 2004.
https://en.m.wikipedia.org/wiki/Loot_box#History
Tf2 wasn't released until 2007, and it didn't ship with any unlocking let alone loot, the first unlockable items were added 2 years later in 2009: https://wiki.teamfortress.com/wiki/Item_timeline_in_2009
I'm baby