Well, thank the Druids. They believed that since November 1st was the beginning of winter, that evil spirits were in their element at this time of year because the nights were becoming longer. It was thought that demons and all types of wicked creatures would be celebrating on the night before November 1st. and that they would be out terrifying innocent people.
So where does the part about the treats come in?
In order to appease these evil ones, the Druids would lay sweets and other foods outside their doors on October 31st. And in an attempt to fool them, the humans would also dress up as ghosts and goblins and witches. They hoped that the creatures would think that they were part of the scary crowd.
Evidently, we’re still trying to do that today.