From what I understand, the tradition of Halloween dates back to ancient Celtic beliefs. October 31st is the day in which the separation between the living and the dead is the thinnest, so people offered food or "treats" to the dead- sometimes they would collect goods and take them to a town square... from what I've heard at least.

I thought it was interesting! How it got to the US? I'm not sure...