Wikipedia
The carving of vegetables has been a common practice in many parts of the world, and gourds were the earliest plant species domesticated by humans 10,000 years ago, primarily for their carving potential. For example, gourds were used to carve lanterns by the Maori over 700 years ago; the Maori word for a gourd also describes a lamp shade.
It is believed that the custom of making jack-o’-lanterns at Halloween began in Ireland. In the 19th century, “turnips or mangel wurzels, hollowed out to act as lanterns and often carved with grotesque faces,” were used at Halloween in parts of Ireland and the Scottish Highlands. In these Celtic-speaking regions, Halloween was also the festival of Samhain and was seen as a time when supernatural beings (the Aos Sí), and the souls of the dead, roamed the earth.
The belief that the souls of the dead roamed the earth at Halloween was also found in other parts of Europe. Jack-o’-lanterns were also made at Halloween in Somerset during the 19th century.
By those who made them, the lanterns were variously said to represent the spirits or supernatural beings, or were used to ward off evil spirits. For example, sometimes they were used by Halloween guisers to frighten people, and sometimes they were set on windowsills to keep harmful spirits out of one’s home. It has also been suggested that the jack-o’-lanterns originally represented Christian souls in purgatory, as Halloween is the eve of All Saints’ Day (Nov. 1) and All Souls’ Day (Nov. 2).
At Halloween in 1835, the Dublin Penny Journal carried a lengthy discourse on the legend of “Jack-o’-the-Lantern”.
In 1837, the Limerick Chronicle refers to a local pub holding a carved gourd competition and presenting a prize to “the best crown of Jack McLantern”. The term “McLantern” also appears in an 1841 publication of the same paper.
There is also evidence that turnips were used to carve what was called a “Hoberdy’s Lantern” in Worcestershire, England at the end of the 18th century.
The term jack-o’-lantern was originally used to describe the visual phenomenon ignis fatuus (“foolish fire”) known as a will-o’-the-wisp in English folklore.
Used especially in East England, its earliest known use dates to the 1660s. The term “will-o’-the-wisp” uses “wisp” (a bundle of sticks or paper sometimes used as a torch) and the proper name “Will”: thus, “Will-of-the-torch.” The term jack-o’-lantern is of the same construction: “Jack of [the] lantern.”