Halloween is one of my favorite holidays, even though trick-or-treating always struck me as an odd tradition given our nation's pervasive religiosity. How did it all come about, then?
A 3 minute history of Halloween from the National Geographic Channel HERE does an excellent job, I think, of answering this question with both speed and depth. While the holiday's origins date back over 3,000 years, the tradition of "trick or treating" apparently began with Irish immigrants to America during the Potato Famine, who brought with them a tradition of committing 'pranks' on Halloween night. By the time of the Great Depression, however, this 'harmless Irish tradition' had evolved into mean-spirited hooliganism and related extortion rackets.
This became such a widespread social problem in America that the tradition of having neighbors give candy to random children on Halloween for the asking was initiated in the mid-1930s to try to reform this growing public problem. And it worked.