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.