Halloween began as the festival of Samhain. It was part of the ancient Celtic religion in Britain and other parts of Europe. At the end of summer, the Celts thought the barrier between our world and the world of ghosts and spirits got really thin. This meant weird creatures with strange powers could wander about on Earth. The Celts had a big party. It was all about scaring away the ghosts and spirits. Later, with the Christian religion, the day became known as All Hallows' Eve - the day before All Saints' Day on 1 November.
America picks up the pace. It's in America that Halloween has really taken off. Irish immigrants to the United States raised the popularity of Halloween during the 19th century. During the 20th century it became more and more popular, with traditions like pumpkin carving and trick or treating becoming part of TV shows, books and movies.
The origins of trick or treating and dressing up were in the 16th century in Ireland, Scotland and Wales where people went door-to-door in costume asking for food in exchange for a poem or song. Many dressed up as souls of the dead and were understood to be protecting themselves from the spirits by impersonating them.