I understand it's just for fun, and it's an achievement / reward system. Out of curiosity, did the Stack Exchange staff get the idea after playing Team Fortress 2 (TF2)?
The event first happened on
Gaming.SE Arqade last year, and the blog post announcing it starts with:
Throughout history, men have worn hats as a way of showing how much better they are than other men. “I buy hats,” a behatted man seems to say. “I am better than you.”
In wartime, hats were a useful way of conferring rank, and ensuring that casualties were confined to the lower classes… During peacetime, hats have been instrumental for men to let the non-hatted know just who is wearing the hat around here.