In the absence of a writer's explicit statement about the purpose of a particular work, we must infer the writer's intentions from what we know about his or her life, travels, interests, and influences. In Washington Irving's case, for example, we know he was born in the late-eighteenth century and grew up in New York City in the early-nineteenth century, and so he would have become familiar with locales close to the city, such as a town now known as Sleepy Hollow (Kinderhook in Irving's days). We also have an interesting comment Irving made about his youth:
My holiday afternoons were spent in rambles about the surrounding country....I knew every spot where a murder or robbery had been committed, or a ghost seen. I visited the neighboring villages and added greatly to my stock of knowledge by noting their habits and customs, and conversing with their sages and great men. (The Sketch Book of Geoffrey Crayon, "The Author's Account of Himself")
Based on this, it is likely, if not certain, that Irving would have picked up local legends that he would eventually use to help create a uniquely American mythology. Whether he intended to create a distinctive "American" story or not, he succeeded in immortalizing a small part of the Hudson Valley with his creative use of Tarry Town, Sleepy Hollow, the Catskills, and their Dutch and English inhabitants.
Along with Irving's exposure to stories centered in the Hudson Valley, Irving, who left America and spent several years in England, is a product of the Romantic Movement in England and was influenced by writers like Lord Byron and Sir Walter Scott. Scott, in particular, used his Scottish background and heritage to frame many of his novels.
Among the characteristics of Romantic literature are an interest in the past, a fascination with the supernatural and mysticism, and a love of nature. Irving's experiences in New York City and its environs, based on his own words, would have given him sufficient material to create stories that fit nicely into the Romantic Period's fascination with the past and the mystical, framed by the natural elements within the Hudson Valley.
In his essay "The Mutability of Literature," a comic argument between Irving and a book in Westminster Abbey about the fate of books that are kept in libraries and no longer read, the book, which is angry that it hasn't been read for years, says:
Books were written to give pleasure and to be enjoyed, and I would have a rule passed that the dean [of Westminster Abbey] should pay each of us a visit at least once a year. (Par. 5)
Although the argument between Irving and the book is couched in humorous terms, Irving likely put his own view on display in the frustrated words of the book he is arguing with—writers have many motivations for writing, but a common purpose is "to give pleasure" to the reader.
In sum, then, although we may never identify with certainty a purpose for a particular work, we can reasonably conclude that Irving wrote "The Legend of Sleepy Hollow" because the story reflects his own history, his affinity for Romanticism, and, quite possibly, a desire to create something unique to the young United States.