This is the Happiness Hat. It detects whether or not you're smiling. If you aren't, it jabs you in the back of the head with a metal spike. Nothing makes people happier than sharp skull pain!
The whole thing is a project by interactive artist and designer Lauren McCarthy, designed to train you towards "Improved Social Interacting." On the one hand, it seems like something out of a dystopian nightmare. On the other, you have such a pretty mouth when you smile! Why not show it off?