Very important. Hugely important. Music can make or break immersion in any game. I've never turned off the music/sound in a game, as I don't even know of a game I've played that had a sound track so bad that I'd turn it off.
The intro music/soundtrack can (and should) pump you up for playing the game. I can't listen to the into soundtracks of Morrowind, Oblivion, Skyrim, Fallout New Vegas, or Mass Effect without wanting to stop what I'm doing and play those games.
A good sound track of a game should reflect the environment you happen to be exploring, but not so intrusive as to override the ambient sounds. It should also transition when you find yourself in a combat situation, and the combat music/soundtrack should reflect the intensity of the situation. What music is appropriate varies upon your personal tastes, but as Zloth said above, most games get it right.
There are times when I'll mod different music into a game, not often, but there are times when you play a game so much, you want a bit more variety. Take Fallout 4, while the base soundtrack is fine, I use the Dark Apocalypse mod by Digital Nightmare exclusively now. Exploration music is subtle, but fitting, and the combat music just rocks, and fits the the post apocalyptic world.
Digital Nightmare - Dark Apocalyptic Soundtrack at Fallout 4 Nexus - Mods and community (nexusmods.com)
Metal Meets Magic
Sometimes, not often, but sometimes, music that you wouldn't think appropriate for a given genre of games just works. I'm a confessed metal head from the '70s, and while I appreciate almost all types of music today, I still have a soft spot for some good metal. It doesn't always mix well in a fantasy setting, but when it does, it freaking rocks. Grim Dawn does it right, and is the closet to that "Diablo Feeling" I've had since Diablo 2. Grim Dawn never gets the press it deserves.
Enter an apocalyptic fantasy world where humanity is on the brink of extinction, iron is valued above gold and trust is hard earned. This ARPG features complex character development, hundreds of unique items, crafting and quests with choice & consequence.
store.steampowered.com
Another one of my favorite ARPGs,, Sacred 2, had a unique quest to actually find an in-game concert preformed by Blind Guardian. Just a side quest that evolved over a large part of the game, but I felt it was truly unique as I've never experienced anything like that; basically a quest based on music. It's an old, and under rated game, but it still stands out.
View: https://youtu.be/JyfE55c_ZjI
And then there's the music of promo videos for a game. The music in a prom can greatly influence a gamers purchasing decision. That can be good, but it can also be deceptive (look no further that Cyberpunk 2077). But there was one promo that influenced me to buy a game that I do not regret, and that was the first Witcher game. It's metal and magic again, Vader, but how can you not be pumped up by that video? I've never regretted that purchase. It had it's issues when first released, but with the free enhanced edition, CD Projekt Red corrected most issues.
View: https://youtu.be/A3GEPkjNh6k
This topic (thanks Zed) brings to mind a related question. Do you ever, after playing a game for a long time (whether hours, or days, or weeks), hear a certain soundtrack in your mind over and over and over; maybe when lying in bed, or at work, or wherever? Sometimes I'll wake up in the morning and have a particular soundtrack playing through my brain. Weird, I know, but it happens.