Some are said to be based on real events, like 'The Amityville Horror'. The Lutz family claimed to have experienced all sorts of paranormal activities in their new home. However, there are also a lot of fictional elements added to make the story more exciting. So it's a mix.
Mostly, they are not. Writers often use the idea of a haunted house as a setting to create suspense and horror. They draw on common fears of the unknown and the afterlife. However, there are a few stories that claim to have a basis in reality, but they are usually full of holes when investigated closely. For instance, some stories about haunted asylums might seem real at first, but when you dig deeper, you find that the so - called evidence is flimsy.