I think it is an exceedingly old Celtic traditon. Called Samhein (sp)
All winter traditionally belonged to the dead in fact they didn't even count it in the calender originally, just hid indoors and tried to placate the spirits (hence giving out candy to the 'spirits' now). I think BC up to maybe 1000AD
The Pumpkin King (king of all the evil bad dudes) could see out of the Jack O Lanterns eyes.
The customes were designed to stop you being possessed by a spirit - apparently if they can't tell who you are they can't 'get' you. 1100 - 1200AD
Like most pagan festivals it was eventually taken over by the church and changed around a bit.
31st OCT became All Hallows Eve (Halloween) because all the bad spirits were allowed out to play for one time in the year bc 1st of Nov was a particularly holy day (I have no idea why)
OK those are all the little bits and pieces I can remember reading over the years, they are from memory so please don't shoot me if I have misremembered
