Back in the day there was a definite link between heavy metal and swords & sorcery (and thus with D&D). About half of us were metalheads to some degree or another, although about not everyone in school was (I'm talking about middle school). Heavy Metal magazine, album covers, etc.
I'm not sure whether the question is, "Why did Heavy Metal have such a strong S&S influence," or if the question is, "Why did D&D have such strong links to heavy metal?"
The link between gaming and metal seems to be much less strong thirty-odd years later, although the link between metal and S&S seems (although I'm not current on heavy metal any more) to be pretty much just as strong from the bits and pieces of more recent metal stuff I've seen on YouTube. Medieval imagery is still in there quite a bit.
Anyway, that's my navel-gaze of the day, with no answers offered, because the dilithium crystals apparently aren't sending any power to the sonic speculator this morning.