The term "Jack O'Lantern" originally meant one of two things. A night watchman (who held a lantern to see by) or "will o' the wisp", which are mysterious flickering lights sometimes seen at night over wetlands.
Another meaning comes in the form of a myth. An Irish man named "Stingy Jack" invited the Devil to a drink. Stingy Jack didn't want to pay, so he convinced the Devil to turn himself into a coin so they could pay. Once the Devil had complied, Jack decided to keep the money and put it next to a silver cross, preventing the Devil from changing back. Jack eventually freed the Devil, with the condition that the Devil would not bother him for a year and that the Devil could not claim his soul if Jack died before then.
The next year, Jack again tricked the Devil. This time the Devil climbed a tree to pick a fruit. While the Devil was climbing, Jack carved a sign of the Cross into the bark. The Devil was forced to make another deal. This time, he promised not to bother Jack for ten more years.
Jack died soon after that. According to legend, God would not allow him into Heaven. The Devil, upset by the tricks, kept his word and would not allow Jack into Hell. He sent Jack off into the night with only a burning coal for light. Jack put the coal into a carved out turnip, and began roaming the Earth with it ever since. The Irish began referring to him as "Jack of the Lantern", and later shortened it to "Jack O'Lantern."
In Ireland and Scotland, people began making their own versions of Jack's lanterns by carving scary faces into turnips or potatoes and placing them into windows or near doors to frighten away Stingy Jack and other malicious spirits. The English used beets instead of turnips and potatoes. Immigrants from these countries brought the Jack O'Lantern tradition with them when they came to the United States and quickly discovered pumpkins made perfect Jack O'Lanterns.