The custom of 'trick or treat' probably has several origins. Again mostly Irish. An old Irish peasant practice called for going door to door to collect money, bread cake, cheese, eggs, butter, nuts, apples, etc., in preparation for the festival of St. Columbus Kill. Yet another custom was the begging for soul cakes, or offerings for one's self - particularly in exchange for promises of prosperity or protection against bad luck. It is with this custom the concept of the fairies came to be incorporated as people used to go door to door begging for treats. Failure to supply the treats would usually result in practical jokes being visited on the owner of the house.
Since the fairies were abroad on this night, an offering of food or milk was frequently left for them on the steps of the house, so the houseowner could gain the blessings of the "good folk" for the coming year. Many of the households would also leave out a "dumb supper" for the spirits of the departed.According to Tad Tuleja's essay, "Trick or Treat: Pre-Texts and Contexts," in Santino's previously mentioned anthology,Halloween's modern trick or treating (primarily children going door-to-door, begging for candy) began fairly recently in the US, as a blend of several ancient and modern influences. In 19th Century America, rural immigrants from Ireland and Scotland kept gender-specific Halloween customs from their homelands: girls stayed indoors and did divination games, while the boys roamed outdoors engaging in almost equally ritualized pranks, which their elders "blamed" on the spirits being abroad that night. Its entry into urban world can probably traced back in mid-19th Century New York, where children called "ragamuffins" would dress in costumes and beg for pennies from adults on Thanksgiving Day. Things got nastier with increased urbanization and poverty in the 1930's. Adults began casting about for ways to control the previously harmless but now increasingly expensive and dangerous vandalism of the "boys." Towns and cities began organizing "safe" Halloween events and householders began giving out bribes to the neighborhood kids as a way to distract them away from their previous anarchy. The ragamuffins disappeared or switched their date to Halloween.
The term "trick or treat," finally appears in print around 1939! Pranks became even nastier in the 1980's, with widespread poverty existing side-by-side with obscene greed. Unfortunately, even bored kids in a violence saturated culture slip all too easily from harmless "decoration" of their neighbors' houses with shaving cream and toilet paper to serious vandalism and assaults. Blaming either Neopagans or Halloween for this is rather like blaming patriots or the Fourth of July for the many firecracker injuries that happen every year (and which are also combatted by publicly sponsored events). Given this hazardous backdrop town councils, school boards and parents in the 1930's invented this custom as it is being celebrated today to keep their kids out of trouble.As far as the custom across the Atlantic goes, by the mid- 20th century in Ireland and Britain, the smaller children would dress up and parade to the neighbors' houses, do little performances, then ask for a reward. American kids seem to remember this with their chants of "Jingle bells, Batman smells, Robin laid an egg," and other classic tunes done for no reason other than because "it's traditional."
Taken from http://www.theholidayspot.com/halloween/trick_or_treat.htm