Epigraphs are like little appetizers to the great entrée of a story. They illuminate important aspects of the story, and they get us headed in the right direction.
"A pleasing land of drowsy head it was,
Of dreams that wave before the half-shut eye;
And of gay castles in the clouds that pass,
For ever flushing round a summer sky."
—James Thomson, "The Castle of Indolence"
The epigraph, a selection from a poem by James Thomson, has some major Gothic street cred. The poem influenced many Gothic writers and was even alluded to in The Mysteries of Udolpho (1794), a novel by Ann Radcliffe that is pretty much the Gothic novel. Irving had been doing his homework.
Of course, Irving makes good use of the poem, too, by allowing it to set the tone for the whole story. If we didn't know better, we'd think Thomson was describing Sleepy Hollow in these verses. That is, before Ichabod Crane busts onto the scene and messes everything up.