In the 5th century BC, in Celtic Ireland, summer officially ended on October 31. The holiday was called Samhain, which means "end of summer", the Celtic New Year. During Samhain, the Druids believed that the dead would play tricks on mankind and cause panic and destruction. They had to be appeased, so country folk would give the Druids food as they visited their homes.
An old Irish peasant practice called for going door to door to collect money, breadcake, cheese, eggs, butter, apples, etc., in preparation for the festival of St. Columb Kill.
Also a ninth-century European custom called souling. On November 2, All Souls Day, early Christians would walk from village to village begging for "soul cakes" made out of square pieces of bread with currants. The more soul cakes the beggars would receive, the more prayers they would promise to say on behalf of the dead relatives of the donors. At the time, it was believed that the dead remained in limbo for a time after death, and that prayer, even by strangers, could expedite a soul's passage to heaven.
Some people think that this led to asking for treats on Halloween in verses or rhymes. Such as:
Deal out, Deal out,
The witches are out!
Trick or treat, you're so neat.
Give me something good to eat.
Nuts and candy, fruit and gum.
I'll go away if you give me some.
Trick or treat, smell my feet.
I know you'll give us lots of treats.
Not to big, not to small,
Maybe the size of Montreal.
I hear a bang, bang, bang
On the door, door, door
A ghost, a witch, a pumpkin, a skeleton and more,
I hear a bang, bang, bang,
On the window too,
A knock, knock, knock,
They want to get you,
It's Halloween Night...BOO!