This is beautifully addressed by C.S. Lewis in Of Other Worlds: Essays and Stories. Here is a passage that describes what I am referring to--especially with regards to children's literature.
The third way, which is the only one I could ever use myself, consists in writing a children's story because a children's story is the best art-form for something you have to say: just as a composer might write a Dead March not because there was a public funeral in view but because certain musical ideas that had occurred to him went best into that form. This method could apply to other kinds of children's literature besides stories. I have been told that Arthur Mee never met a child and never wished to: it was, from his point of view, a bit of luck that boys liked reading what he liked writing. This anecdote may be untrue in fact but it illustrates my meaning.
Whether we are talking about children's literature or a work for older audiences, one dimension of this respect lies in whether, or not, the story comes first. Many years ago, for example, I tried to use a short story format to write a tale to prove that some people find right behavior wrong and wrong behavior right. These days we hardly need reminding of this, but, at that time in my life, I was exploring the moral compass of a drug dealer. The story didn't work for many reasons, but probably the main reason was that it began as a kind of moralizing piece; the story was secondary to the message, and this almost always brings ruin to the writer's endeavor.
When it comes to fiction for older readers, my pet peeve is sanitizing dialogue or situations for the taste and preferences of the writer or a select group of potential readers. If you have a story, tell it truthfully. As Flannery O'Connor so eloquently put it,"Fiction is about everything human and we are made out of dust, and if you scorn getting yourself dusty, then you shouldn't try to write fiction. It's not a grand enough job for you.”
Not too long ago, I was discussing a work of fiction with some fellow Catholic writers who were very passionately debating their view that profanity had no place in fiction--especially the writing of a Catholic. While I don't agree with the premise at all, it did encourage me to lighten the profanity in my own novel, The Blood Cries Out. (As an aside, I hope when fellow writers make recommendations along these lines (that you accept in part), they have the courtesy to at least read your work. If they have no interest in the art you create, I'd just as soon they keep their writing suggestions to themselves; they're not part of your audience.) Some might say that my lightening of the profanity was an unnecessary sacrifice to political correctness, but I suggest that realism and truth can be achieved with a lighter touch at times. Finding that balance can be hard, but it's what lies at the heart of writing that matters the most: truth.
Like I wrote for Seattle Pacific University in "Art and the Christian Gospel," we engage the culture around us for Christ by seeking truth even if we happen to be writing fiction or creating another form of art.
Art calls us to worship; it also empowers us to engage our culture with the gospel. Given the present world crisis, I believe Christians have a responsibility to address the moral issues facing us in this troubling time. The words of Christian writers and theologians from C.S. Lewis to Dietrich Bonhoeffer still give us much to consider and discuss. From Michelangelo to Handel, our Christian heritage is also replete with the finest artists and composers who have ever lived. This rich Christian perspective plays a vital role within our culture. It is our responsibility to ensure that this legacy endures and continues.
Christians are aware that there is more to life than what simply meets the eye, and that the spiritual world is just as real as the earth they are standing upon. The Christian must focus and hold on to “whatever is true, whatever is noble, whatever is right, whatever is pure, whatever is lovely, whatever is admirable.” That is the only way we can maintain our clear vision and grip on the eternal priorities facing us.