Unlike RS who have only existed for 20 years, Trick-or-treating has existed since medieval times.
Back then, it was known as "guising" in Scotland and Ireland. Young people dressed up in costumes and asked for food or money in exchange for songs, poems, or other "tricks." Today, the tradition has morphed into children to getting dressed up and asking for sweets.
Halloween all started as a pre-Christian Celtic festival called Samhain (which means "summer's end") held around the first of November. It celebrated the final day of the harvest and the crossing of spirits over into the other world. People in Ireland, the United Kingdom, and Northern France would ward off ghosts by lighting sacrificial bonfires, and, you guessed it, wearing costumes!