History

1882 illustration which depicts people in England in earlier times begging for soul cakes.
The concept of trick-or-treating probably dates back to the early All Souls’ Day parades in England. During the festivities, poor citizens would beg for food and families would give them pastries called “soul cakes” in return for their promise to pray for the family’s dead relatives. The distribution of soul cakes was encouraged by the church as a way to replace the ancient practice of leaving food and wine for the returning spirits on Halloween night. The practice, which was referred to as “going-a-souling” was eventually taken up by children who would visit the houses in their neighborhood and be given ale, food, and money.
The tradition of dressing in costumes and masks on Halloween finds its roots in both European and Celtic history. On Halloween, when it was believed that ghosts came back to the earthly realm, people thought they would encounter the ghosts if they left their homes. Therefore, to avoid being seen by these ghosts, people would wear masks when they left their homes after dark so that the ghosts would mistake them for fellow spirits.
In North America, the practice of trick-or-treating dates to the late 1920s.
Video
Tricks
If no treats are received, the visitors may try to pull pranks on the people’s houses to trick them. Well-known pranks include covering people’s property with toilet-paper, smearing soap o windows or throwing flour or eggs at houses, all of which are forms of vandalism.
Would-be tricksters should keep in mind that egging a person’s house or car can cause permanent damage to the paint job if not taken care of immediately, with a belief that it can cause more harm in colder environments due to the freezing effect. As eggs are organic, it will also leave a rotting smell as the egg decays over time.
Some homeowners use an alternate interpretation of the phrase “trick-or-treat”, choosing the trick option, which is not traditionally implied as an option for the homeowners. They will then perform a magic trick for the trick-or-treaters.
See the article on trick-or-treat on Fandom’s Home wiki.