"Jack o'lantern" comes from the Irish legend of Stingy Jack
Legend has it that Stingy Jack invited the devil to have a drink with him, but Jack didn't want to pay for the drink, so he convinced the devil to turn himself into a coin. Instead of buying the drink, he pocketed the coin and kept it close to a silver cross in his house, preventing the devil from taking shape again.
He promised to let the devil go as long as he would leave Jack alone for a year – and that if Jack died, the devil wouldn't claim his soul.
After a year, Jack tricked the devil again to leave him alone and not claim his soul. When Jack died, God didn't want such a conniving person in heaven and the devil, true to his word, would not allow him into hell.
Jack was sent off into the night with only a burning coal to light his path. He placed the coal inside a carved-out turnip and has been roaming the earth ever since.