Sadism and masochism are ways for people to explore their likes and desires in a safe way. In fiction, these can be used to explore these same feelings in a creative way. For example, a character might want to do something that they know is wrong, but they can't bring themselves to do it in real life. The story might allow them to do it in a safe way, where no one is actually hurt but they can still explore those feelings to figure out more about themselves. Sadism and masochism in fiction can be used to tell stories about characters dealing with difficult emotions, and learning about their desires.