On Celtic-Pagan influences; bonfires; JV Gods:
Celebrated as early as the 12th century, Samhain, which means “Summer’s end”, was a Celtic festival held around the end of October that marked the end of the harvest and the start of a “darker season”.
Darker seasons meant a) the sun literally wasn’t up as often, and b) the “Aos Si” (essentially JV gods, or spirits/fairies) were active and needed to be bribed with foodstuffs or they’d murder your cows -- so people would leave offerings. It was also a time when the souls of dead people not seen by Haley Joel Osment came back to their homes to hang out. To make them feel at home, people would light their nicer Yankee candles, say prayers, and then create huge bonfires, because dead souls are essentially just like drunk teenagers in fields.
After prayers, dinner, and fire with the dead souls, people would go out “guising” (e.g. wearing a disguise!) to fool or imitate the Aos Si (history isn’t clear on this distinction), often using the ash from those bonfires to blacken their faces, holding carved-out turnips (pumpkins are native to North America) with candles in them, and going door-to-door singing songs or reciting racy poems in exchange for food. If you didn’t give these weird people dressed up like JV Gods some of your Stouffer’s, they would threaten to do things to your home. So yes, in this version, trick-or-treating essentially started as a kind of f***ed-up blackmailing scheme.
On Christian influences; vengeful soul cakes; slutty cobblers' apprentices:
Move aside, Pagans! Christ’s followers also take credit for some Halloween action, mainly because it falls on the the night before All Hallow's Day, aka All Saints' Day, aka Hallowmas, aka Hallowtide,
aka Hallow Man aka DJ Kevin Bacon -- no... that’s about all of them. On these days, Christians pray for recently departed folk to get up to Heaven, and also pray for saints. People also baked “soul cakes”, which have nothing to do with movies produced by Babyface in 1997, and everything to do with making baked goods for “all christened souls.” Once you made your cake, poor people would come knocking door-to-door to get some, in a process called “souling”. If you didn’t have a cake, the poor people would say passive-aggressive things about you in Latin. So that’s their version of where/how trick-or-treating started.
In terms of costumes, the Christians believed that on All Hallow's Eve, throngs of angry, vengeful souls were wandering around with murder-lust in their eyes, looking to enact revenge on anyone who wronged them before they got shipped off to Heaven/Hell. In order to avoid this petty deathly vengeance, people dressed up in costumes to disguise their identities, hoping this would happen:
Soul they wronged: Argggghhh!! Are you Ben Robinson?!?! I will bring upon you a fiery, torturous death from which there is no escape!!!
Ben Robinson: Of course not. I’m just a slutty cobbler’s apprentice.
Soul they wronged: Oh, my mistake.