Candy is traditionally given out on Halloween to children who dress up in costumes and go door-to-door asking for candy in a custom known as trick-or-treating. It is increasingly common for children to trick-or-treat in retail stores, or to receive candy at church or community carnivals.
According to The Atlantic, candy was never originally part of Halloween and didn't become a major staple in the Halloween tradition until the late 1950s, when candy companies began marketing candy as the perfect Halloween treat. By the early part of the 1970s, candy became the obvious choice for people to hand out to trick-or-treaters.
Candy makers had already been using holidays as a way to push candy sales. A perfect example of this is when candy companies came up with the heart-shaped chocolate box in the early 1900s to market candy on Valentine's Day.
Going door-to-door on Halloween didn't become a tradition until the late 1930s. By the 1940s, dressing up as monsters and ringing doorbells became a nationwide affair. Throughout the 40s and even into the 50s, kids didn't receive candy while trick or treating. Instead, they received cakes, fruits, coins and even toys.
Since handing out fruits and toys ended up costing a lot of money for people who received many trick or treaters, candy companies saw an opportunity to market candy. It was cheaper than giving toys and other goods, and kids loved it. From then on, candy became a major player during Halloween.