Why is Candy Given Out on Halloween?

Kids are always happy to get candies and remember the day well so while trick-o-treating they get candies. Halloween the scary demon says stories about ghosts.The idea was to please the spirits with some food at the doorstep that night.