When and why did Gothic Literature originate and what is gothic literature?
The earlier responses describe the origin of Gothic literature and its key components. It is perhaps useful to know, too, that there are two key groups of Gothic texts in English, representing the original Gothic period and the so-called "Gothic revival." Gothic is notoriously overblown and dramatic in its tone and storylines, but it also tends to reflect the concerns and uncertainties of society at the time of writing. Thus, the Gothic literature born out of Romanticism in the early nineteenth century is different to the texts from the fin-de-siècle (turn of the twentieth century) which demonstrate shifting social preoccupations.
Consider, for example, Mary Shelley's Frankenstein, also a progenitor of science fiction. Frankenstein is a reaction to the Enlightenment, the spread of science; many at this time began to fear that science would displace religion or that men would take it upon themselves to play God, with catastrophic results. This was a key fear in society at that time. In fin-de-siècle texts, religious uncertainty had ceased to be such a prevailing issue. Instead, we see strong evidence in Gothic literature of fear of the self. Wilde's Picture of Dorian Gray, Stephenson's Dr Jekyll and Mr Hyde,and Stoker's Dracula all play on the idea that there is a corruption lurking underneath the veneer of a polite society. In Victorian London, rigid structures of gentility hid an underbelly of crime and scandal, workhouses and child prostitution. So, a handsome young man may have a portrait in the attic on which his sins are written, while a respectable doctor may transform at night into a murderous villain. Ultimately, in both cases, the villainy is the victor. In Stoker's Dracula, the mysterious and fearful "other" slowly penetrates and damages even the most innocent of characters, male and female alike, and transforms them into something like itself.
The Gothic, and the function of the Gothic, does not end with the fin-de-siècle group of novels. There are stories written today which are still consciously Gothic, with all its trappings (isolation, the haunted house, the lone woman, the dark, the pathetic fallacy, etc.). We might better look to science fiction, however, to see the key concerns of the Gothic represented: as society shifts, we now are more likely to see our current fears—alienation; the rise of robotics; artificial intelligence—represented in sci-fi novels and television programs, the true descendants of the Gothic.
Considered the first Gothic novel, The Castle of Otranto (1764) originated in a dream, according to its author, Horace Walpole. Indeed, the narrative does contain a certain dreamlike quality and free play of the imagination.
Gothic literature is characterized by elements that have always intrigued people. After all, there is always something about the darker side of man that arouses curiosity.
The setting is a castle
(Walpole explored and took notes on Gothic cathedrals and castles that he explored on summer tours.)
Sometimes the setting is an old mansion. These buildings are both a physical and a psychological presence. Architecture becomes an embodiment of fate.
An atmosphere of mystery and oppression
This atmosphere emphasizes the powerlessness of the characters as they are manipulated by forces that they are unable to fully comprehend. Images often appear and sounds are emitted. Winds blowing curtains mysteriously create visual effects of mystery.
Supernatural happenings or inexplicable events
Ghosts appear, and inanimate objects seem to move. In Poe's story, "The Fall of the House of Usher," for instance, the house makes sounds.
Women threatened by a tyrannical male
The main female character may be forced to do something that she does not want to do or marry someone she does not love.
The metonymy of horror and gloom
Often an object or condition that is related to something is used in its place. For example, doors creak and open, suggesting a ghost passing. Other examples are thunder and lightning, footsteps approaching, baying of dogs in the distance, clanging chains, and ominous weather, namely, rain, wind, and lightning.
Gothic literature, like romantic literature, was at least in part a reaction against neoclassicism. In fact, Gothic literature is a form of Romanticism. It was popular in the late 18th and early 19th centuries, just like Romanticism. Gothic novels are usually set in castles, monastaries, spooky old mansions. They also usually involve ghosts or some form of the supernatural. They involve mystery and terror and the grotesque. The world of the Gothic is usually warped in some way.
The word was originally, at least as far as I know, applied to Medieval architecture. According to The Concise Oxford Dictionary of Literary Terms, the word was therefore associated with superstition and became the term applied to novels we now call Gothic.
Emily Bronte's Wuthering Heights and Mary Shelley's Frankenstein are classic examples from England, and Poe is an American Gothic writer. Also, in America, Southern Gothic became popular in the 20th century. Writers like Faulkner and Welty made it popular. Though Southern Gothic writers no longer set their stories in castles, etc., the mystery and terror, and particularly the grotesque, connect this offshoot to the original.
Why is a difficult question, but in English literature at least, Gothicism came as an offshoot of Romanticism in the early 19th century before the commencement of the Victorian era. Authors like Ann Radcliffe and Horace Walpole began the trend with texts like Mysteries of Udolpho and The Castle of Otranto. M.G. Lewis's The Monk was another important text, that was more psychological than the more outward looking horror that we see in the other two.
Gothic literature took off from the mysteriously spaciously Gothic architectonics of remote and grand castles and the element of horror was inextricably related a place of such kind.
Later on authors like Edgar Poe used the genre in a purely psychological way and even in contemporary literature, we see the Gothic trope being used to connote existential horror. Beckett's late plays (like Footfalls) are an example.
As for the 'why', perhaps what Edmund Burke noted in his short text on the 'Sublime', the Gothic form had a curious appeal in terms of weaving a beauty of the unpleasant, the horrifying and even the grotesque. It had and still has a powerful impact on the human senses. Austen's Northanger Abbey remains a classic burlesque of the Gothic novel.