Caused by extreme cold temperatures hitting the roof of your mouth, stimulating the trigeminal nerve and sphinopalatine ganglion, which in turn causes vasodilation of your blood vessels. As the blood vessels in your brain enlarge, they press against the meninges (the covering of your brain) and cause intense pain. This is pretty close to what a migraine feels like. If you've never had a migraine, imagine a brain freeze that lasts for 30 minutes to several hours, sometimes lasting days.
So are you going to share the ice cream or do we have to beat you up for it?