Halloween evolved from Samhain (sah-win), the new years festival of the Celts.
Samhain was believed to be when spirits crawled out of the otherworld. These spirits could either be helpful or harmful; Samhain was supposed to attract the helpful ones and deter the harmful ones. One of the strategies to deter harmful spirits was lighting a fire inside of a carved turnip, which is where jack-o-lanterns come from.
The name Halloween derives from All Hallows (holy) and Eve, meaning the day before, in reference to All Saints Day, November 1, a Catholic holiday. Samhain was renamed and some of its rituals changed when Christianity came to Ireland.
Halloween came to America with Irish immigrants during the 19th century. By the 1930s, non-Irish were celebrating as well. The idea of Halloween being a scary holiday originated in America with the Puritans. The Americanised Halloween kept the dressing up in costumes and asking for food (mumming), and the setting of carved vegetables on fire. The Americanised Halloween also re-introduced Halloween to adults, since originally mumming was done by both children and adults. All in all, Halloween has evolved a lot over the centuries.