Stephanie Meyer is the first author I know of who let people know on a wide scale the sort of music that inspired her to write; I remember going up to the music section of Borders a couple of years ago and seeing a large central display with the Twilight covers plastered over it, advertising that the selection of Muse below was what had accompanied the writing of Twilight.
The role of music in writing comes up frequently on various of my writing forums, too: the validity of inspiration by music, stories written specifically to accompany certain songs (referred to as songfics), whether background music is distracting or beneficial, the genres of music best conducive to certain kinds of writing, theme songs for certain characters or stories and whether that extra dimensionality helps hold the characters in the writers head.
The answers to all those questions vary from writer to writer: some can only work in utter quiet, and consider using music to set a mood frivolous, others listen to classical to stimulate the creative portions of their brain, still others have a hard time writing unless they have a specific playlist whose lyrics exactly reflect the mood of the piece.
Like every other aspect of writing, there is no one true way, none that is inherently superior to others. As long as a good story is coming out of it, the tools and environment that foster it are little more than interesting side notes.
Music can definitely be a tool. Like lighting or temperature or having other people in the room, it can set the mood for writing. I know I would have trouble writing most parent-child affection moments to an accompaniment of death metal. With collaborations, I’ve found jointly putting together a soundtrack helps us gel the tone of the world: if we’re both suggesting 90s punk, we have roughly the same idea of the tone, if one of us is suggesting disco and the other bluegrass, we obviously have more discussion to do to make sure we’re on the same page for the story. I’ve found this focus on tone useful for my solo writing projects as well, though to a lesser degree, as, well, I’m the only one working on the world.
It’s possible to take enjoyment of it as background and use for mood setting too far, of course: if you find that you’re unable to write unless listening to a particular song, that’s probably not conducive to better writing in general.
Beyond the writing end, music can be a good way to engage readers: the Twilight soundtracks were intensely popular, and people liked listening to them as they read the books. It creates a more immersive experience to have the ears engaged as well as the eyes, and can help the reader be more fully transported to the author’s world.
It can also help the author engage the readers, as almost any peripheral to the story itself can: asking for music recommendations from readers creates a community atmosphere and can foster a feeling of being invested in the story. And who doesn’t want readers who feel personally engaged?
If you’re interested in what I listen to as I write this, you can find it here. I’m always happy to take recommendations.