Before the narrator introduces the reader to the story's main character, he pauses to recount the story of William Kidd, also known as Captain Kidd, a notorious pirate active about two decades before the story is set. The events of Kidd’s life—his rise to wealth and his ultimate downfall—foreshadow those of Tom's.
Under one of these gigantic trees, according to old stories, there was a great amount of treasure buried by Kidd the pirate [...] The old stories add, moreover, that the devil presided at the hiding of the money, and took it under his guardianship; but this, it is well known, he always does with buried treasure, particularly when it has been ill-gotten. Be that as it may, Kidd never returned to recover his wealth; being shortly after seized at Boston, sent out to England, and there hanged for a pirate.
The search for Captain Kidd’s buried treasure becomes an important plot-point, motivating Tom to make a deal with Old Scratch, but Irving also reminds the reader of Kidd’s fate: he never lived to enjoy his stolen goods, but was instead captured by the British authorities and hung to death in London. Like Kidd, Tom will make a deal with the devil in order to get his hands on a large but “ill-gotten” fortune, and ultimately, Tom will fare no better than Kidd. His loss of both his “ill-gotten” gains and his life is thus foreshadowed from the very beginning of the story, allowing the reader to anticipate the story's moral.