Halloween as we commonly know it today it grew out of the Christian observance of All Saints Eve (or All Hallows Eve), which may have supplanted pagan harvest festivals. It was a time given over to remembering the dead, both saints (hallows) and ordinary folk, from which the morbid modern associations originated. How the Christian practice of remembrance was transformed into the modern secular and commercial observance is unclear, but likely had its roots in the US, although elements - particular the dress-ups - have been known for hundreds of years.
The practice of trick-or-treating, where children go from door to door seeking sweet treats, was largely unknown in Australia till recently, but has now grown into an annual revenue boost for the confectionery industry. In the small country town of Korumburra, the entire historic tourist attraction of Coal Creek is given over to the celebration, with thousands of costumed revellers filling the park. Judging by the queues, the most popular attractions are the trick-or-treat stations, where children wait patiently to collect a few treats. To me, it looks like it all harks back to the ancient harvest festivals, where people feasted after the crops were safely gathered and stored. Looks like we've gone full circle.