i actually thought about this (the metal part specifically) before and did a bit of research and as far as i know, there are quite a few reasons:
1.) as others said, of course climate, culture, landscape, history, mythology..., just the life scandinavian people live inspires musicians
2.) swedish kids get supported with learning instruments. i think they even have to choose an instrument to learn at school? but at least there are a lot of music schools (and they aren't that expensive/ maybe even free) so naturally most kids learn how to play an instrument and if they they ever want to start a band, they already have some musical knowledge
3.) the swedish metal scene IS this big because the swedish metal scene WAS this big before. sounds stupid, but first of all swedens history with extreme music makes it generally more accepted than it is in other countries. second of all, most cities are the home of some popular bands so swedish people are really likely to discover metal, get inspired by it and also motivated because they know others from their hometown got successful with playing music. (if this is hard to understand, try to compare how you think people from i dont know, hawaii, would feel about starting a metal band vs how people from gothenburg would feel. i think, the latter would be way more confident in themselves)
4.) similar to the point above, sweden probably has a bigger metal community than other countries and of course a bigger community creates a bigger community. if there are more live shows, record shops and so on, people will more likely discover it and become a part of that scene. also new bands can get gigs, signed by a record label, featured in zines... easier
5.) in worldwide comparison, sweden is fairly progressive and rich in general so kids are more likely to even get the possibility to start a musical career. their parents probably at least allow them to do so and they will be able to afford the gear and maybe even a gap year or something to do a concert tour abroad, record an album etc
and if you wonder how i explain how all of this started in the first place:
6.) i think there was a bit of luck too. somehow some metal bands appeared in this country (just as the did in a lot of others at the time) and they were quite good at... popularizing... the music. i mean, think about all the mayhem stories, they HAD to be featured in the media so all the edgy teenagers discovered especially black metal and helped the scene evolve. most people in africa (just an example of a continent that isn't as well know for its metal scene) probably didn't even know about this kind of music. it really only needs a few people to start something big, all that matters is that they find a way to spread whatever they are doing and reach others who eventually will join them
edit: most of this probably applies for norway and finland too