This might sound like people are quite horrible, for enjoying the misery of others, but this is a human trait. I am not sure that "enjoy," though, is always the correct word. We are deeply interested in the misery of others, and sometimes this is actual enjoyment.
First, I would say that it is consoling to us to know that others suffer, as we suffer in life from time to time. Even in fiction, there is a kind of "misery loves company" dynamic.
Second, watching or reading about the suffering of others is a kind of emotional release for people. I have a friend who watches Steel Magnolias over and over again and says, "I love that movie so much. It makes me cry no matter how many times I've watched it."
Third, watching or reading about others in misery can be a learning experience, teaching us something about ourselves or something about others. I have gained insights into myself and other people through reading and movies.
Fourth, when the people who suffer in books and movies are deserving of their fates, it makes us feel like the world is a fair and orderly place. Often it seems to us that the bad are rewarded and the good are punished. A movie or book that rewards the good and punishes the bad is quite satisfying to watch.
Fifth, there is a dynamic called schadenfreude. This is experiencing satisfaction over someone else's misery. If you have ever had a really bad argument with someone, and then that someone tripped and fell, there is a little childish part of us that says "Serves you right!" and takes pleasure in the pain. I have also observed this dynamic when someone married his "mistress" and the marriage did not go well. There were those who took pleasure in that result. This dynamic can also be the result of the thought that if something bad happens to someone else, it has not happened to you. This is magical thinking. If lightning strikes someone else, it can certainly strike you, too, but nevertheless this can be our response.
Some of this makes it sound as though human beings are not very nice, but the fact is that we have a side to us that does enjoy watching suffering. The reasons are not necessarily evil, though.