Hallowe'en originated in the druidic holiday of death associated with
Samhain.
From Wikipedia:
Although modern Halloween is a secular holiday, it evolved from the pagan Celtic season of Samhain, which was Christianized as the feast of All Saints.
Bonfires played a large part in the festivities and hundreds of fires are lit each year in Ireland on Hallowe'en night. Villagers cast the bones of the slaughtered cattle upon the flames. The word "bonfire" is thought to derive from these "bone fires." With the bonfire ablaze, the villagers extinguished all other fires. Each family then solemnly lit their hearth from the common flame, thus bonding the families of the village together.
Like most Celtic festivals, it was celebrated on a number of levels. Materially speaking it was the time for gathering in food for the long winter months ahead, bringing people and their livestock in to their winter quarters. To be alone and missing at this dangerous time was to expose yourself and your spirit to the perils of imminent winter. In present times the importance of this part of the festival has diminished for most people. From the point of view of a tribal people for whom a bad season meant facing a long winter of famine in which many would not survive to the spring, it was paramount.
From an astrological perspective, the rising of Pleiades, the winter stars, heralds the supremacy of night over day, the dark half ruled by the realms of the moon.
In the three days preceding the Samhain month the Sun God, Lugh, maimed at Lughnassadh, dies by the hand of his Tanist (his other self), the Lord of Misrule. Lugh traverses the boundaries of the worlds on the first day of Samhain. His Tanist is a miser and though he shines brightly in the winter skies he gives no warmth and does not temper the breath of the Crone, Cailleach Bheare, the north wind. In this may be discerned the ageless battle between the light and dark and the cyclic nature of life and the seasons.
It was the time to placate the supernatural powers controlling the processes of nature. In addition, Halloween was thought to be the most favorable time for divinations concerning marriage, luck, health and death. It was the only day on which Christians imagined that the help of the devil was invoked for such purposes.
Even later, in the 11th century, the church would make November 2 All Souls' Day, a day to honor all the dead: all the Christian souls in the half-world of Purgatory. Catholic doctrine most clearly reveals the liminal or threshold connection between the two worlds: "that the souls which, on departing from the body, are not perfectly cleansed from venial sins, or have not fully atoned for past transgressions, are debarred from the Beatific Vision, and that the faithful on earth can help them by prayers, almsdeeds and especially by the sacrifice of the Mass." (Catholic Encyclopedia, 1910: 'All Soul's Day').
All Soul's Day was accepted and Christianized by Odilo (died 1048) in the Cluniac monasteries, and its observance spread through the Celtic north before it was introduced into Italy.
The custom survives most accurately in Ireland, where the last Monday of October is a public holiday. All schools close for the following week for mid-term, commonly called the Hallowe'en Break. As a result Ireland is the only country where children never have school on Halloween and are therefore free to celebrate it in the ancient and time-honoured fashion.
The custom of trick-or-treating is thought to have evolved from the European custom called souling, similar to the wassailing customs associated with Yuletide. On November 2, All Souls Day, Christians would walk from village to village begging for "soul cakes" - square pieces of bread with currants. Beggars would promise to say prayers on behalf of dead relatives helping the soul's passage to heaven. The distribution of soul cakes was encouraged by the church as a way to replace the ancient practice of leaving food and wine for roaming spirits at the Samhain. See Puck (mythology).
In Celtic parts of western Brittany. Samhain is still heralded by the baking of kornigou. Kornigou are cakes baked in the shape of antlers to commemorate the god of winter shedding his "cuckold" horns as he returns to his kingdom in the Otherworld.
Irish emigrants from the Irish Potato Famine of 1845-1846 brought with them the holiday of Halloween to the United States.