In the words of Oscar Wilde,
"There is no such thing as a moral, or an immoral book. Books are either well-written, or badly written."
There is a lot of logic in the quote. A work of fiction is produced for the sake of producing a work of art under the field of literature. It is a manifestation of the ideas of the writer at the time the piece is written, and it should not be meant to give a moral statement. If that were the case, and this is entirely under a Wildean perspective, then the work of literature ceases to be artistic and, in turn, becomes a plain didactic document.
Under a different perspective, one could also argue that literature could be used as a conduit for the teaching of morality if the topic is treated as a fable, a parable, or using a completely allegorical scenario, such as in the case of Young Goodman Brown.
Other than that, fictional literature should not be used to change behaviors, but to invite the reader to connect to the story, and to discover the many dimensions of the self.