I love rock, metal and all their subgenres and sistergenres but although they are now connected to the occult both by outside sources and themselves (lyrical content, symbolism, etc) this was not the case with the earliest examples of rock to my knowledge, so how did this really begin?
1950s rock'n'roll, by and large, has little occult symbolism or lyrical content - instead the lyrical focus is on love, sex, dancing, and teenage life (in much the same way that the lyrical focus of most pop music today is on love, sex, dancing, and teenage life). There's a couple of exceptions in 1950s rock & roll, however, which basically play on voodoo symbolism as a schtick not meant to be taken entirely seriously. Bo Diddley is one: his 1955 track 'Bo Diddley' mentions 'mojo come to my house, ya black cat bone', while his 1956 track 'Who Do You Love?' also has a voodoo feel to it. Bo Diddley's schtick was a sort of primitivism (the 'bo diddley' being a primitive string instrument), and Diddley was using occult references along with African-based rhythms as a sort of way of evoking 'primitive' African roots. The other is the has-to-be-seen-to-be-believed Screamin' Jay Hawkins, whose song 'I Put A Spell On You' hams up the voodoo stuff in a 'black Vincent Price' kind of way.
In terms of the rock music of the 1960s, one important source for occult symbolism is in the blues. In the wake of the Beatles, a British blues movement came to prominence - groups like The Animals, The Rolling Stones, and the various groups Eric Clapton was in (The Yardbirds, John Mayall's Bluesbreakers, Cream, etc) - which found inspiration in the acoustic Delta blues of the 1920s-1930s and the post-war Chicago electric blues on labels like Chess. The symbolism of the deal with the devil at the crossroads was common in the Delta blues - 'Cross Road Blues' and 'Me And The Devil Blues' by Robert Johnson are two obvious examples (it's been argued that the specifics of this symbolism has roots in west African theology reinterpreted in the black Christian environment of the Mississippi delta). Similarly, post-war Chicago blues artists like Muddy Waters (e.g., 'Hoochie Coochie Man') and Howlin' Wolf (e.g., 'Evil') played up voodoo symbolism. Anyway, of the British blues movement, The Animals covered 'I Put A Spell On You' in 1965 (playing it straight, rather than for comic effect). 'Hoochie Coochie Man' was covered by Manfred Mann in 1964 and the Graham Bond Organisation in 1965. Eric Clapton's group Cream was covering 'Cross Road Blues' live in 1966 and eventually released it as 'Crossroads' in 1968.
However, as far as the British blues movement went, some of the voodoo references came across as ...exotic to British audiences rather than eerie and foreboding. Additionally, in the heyday of psychedelic drugs such as LSD, rock musicians started experiencing unsettling, occult-seeming experiences - were they bad trips or genuine occult experiences? This is reflected in a variety of music from the era. The Rolling Stones' overtly psychedelic 1967 album was titled Their Satanic Majesties Request (e.g., the track 'We Love You'). Pink Floyd's 1967 Piper At The Gates Of Dawn album has a track called 'Lucifer Sam', playing around with witches' familiar imagery. 1966 saw the release of Donovan's song 'Season Of The Witch', with a session musician by the name of Jimmy Page prominently featured on guitar. An American psychedelic pop group who released their debut album in 1967 called themselves 'H.P. Lovecraft'. And the American rock group Love released a single in 1966, 'Six And Six Is', and an album in 1967, Forever Changes (e.g., 'The Red Telephone') with occult overtones.
In the later 1960s, the British folk-rock movement chronicled in the book Electric Eden by Rob Young also dabbled with occult imagery, seeking to portray a weird old England a la that chronicled in (the 1970s version of) The Wicker Man. I've no doubt that many a metalhead has bought an album by the band Pentangle sight-unseen and discovered to their horror that it's psychedelic jazz-influenced folk rock with Joan Baez-style vocals. Bands like Pentangle and Fairport Convention often did versions of traditional songs like 'The House Carpenter' which featured narrators coming into contact with powerful occult beings.
These various cultural currents came together by the 1970s, when you get bands whose whole image more-or-less revolved around the occult, like Led Zeppelin or Black Sabbath. Led Zeppelin neatly tie all these trends in a bow: Jimmy Page had played in a British blues rock band (The Yardbirds) as they fought to stay on top of the psychedelic trend, and played prominent parts in more than a few psychedelic singles of 1966-1967. There was also a fascination in Led Zeppelin with the British folk-rock movement; 'Black Mountain Side' from their first album is heavily based on an arrangement by Pentangle guitarist Bert Jansch, while Fairport Convention singer Sandy Denny is prominently featured on 'Battle Of Evermore', from Led Zeppelin IV. Jimmy Page was also famously fascinated by the occult, to the extent of buying the occultist Aleister Crowley's former residence, and representing himself in symbolic form on Led Zeppelin IV using a symbol from a 16th century alchemical text (the 'zoso').
Sources:
Ted Gioia, Delta Blues
Andrew Hulktrans, Love's Forever Changes (33 1/3)
Rob Young, Electric Eden: Unearthing Britain's Visionary Music
Erik Davis, Led Zeppelin IV (33 1/3)
One of the most entertaining books I've ever had the fortune to read, and reread again, is Ozzy Osbourne's autobiography, I am Ozzy. While I have read more than my fair share of rock and roll biographies, it's the rare book that I feel confident recommending to the general public, because even if you couldn't care less about the subject, the book itself is just plain entertaining.
So for starters, rock and roll was never entirely the kind of thing a good Christian would be involved with. Even when you get away from Jerry Lee Lewis' issues and AC/DC being on the "Highway to Hell," the simple fact was that the music was originally for dance halls for young people to drink, smoke, and possibly find themselves in the back seat of a car doing things they weren't supposed to be doing before marriage.
The 1960s brought a whole different flavor to this; while anti-war sentiment is hardly theologically un-Christian, Conservative America was generally Christian and generally aligned with the War, and the Hippies were generally not church-going and were tending to do those sex and drugs things that Christians are definitely opposed to.
Now I'm telling you about stuff that is merely not Christian, and stuff that is particularly American, just to fill in the backdrop for where the association truly began, which as you'll gather from my first paragraph is the story of a little band called Earth, made of 4 kids from a blue-collar English town, Birmingham. Earth formed when the most talented guitarist in the town was victim to an industrial accident that lopped off his fingertips, and he not only had to change the way he played the guitar to do so, he was desperate enough to grab the craziest kid in school to join the band as a singer largely because he had his own PA system -- and after the accident, few were desperate enough to board that particular ship. (Would-be rock stars, take note; owning his own PA system is also how David Lee Roth smuggled his way into being in the band with his home-town's best guitarist and became the lead singer of Van Halen.)
So Earth struggled and worked on their craft at the beginning in the middle of hippies, Free Love, the Beatles, flower power. Songs were all about peace and love and good happiness stuff.
Two things happened to change everything. First, there was another band touring around that time that was already named Earth, so they needed another name. And second, they went out to watch a horror movie (not their first), which Ozzy recalls as having had Vincent Price in it, and they got the notion that they could try to be for Rock and Roll what horror films (which they all enjoyed) were for the cinema.
So Iommi sat down with his detuned guitar (for practical reasons -- it was easier to play with his finger prostheses that way; that this also gave his guitar a unique sound that went well with the with the new direction was a bonus) and they began the songs; and not only did they find themselves inspired, they quickly found an audience; here was something that, for those people, they'd never heard in rock 'n' roll before, and they liked it.
Take one of their very first songs, titled "Black Sabbath". Not only are the lyrics dark...
Satan's sitting there, he's smiling
Watches those flames get higher and higher
...but the guitar riff is a diminished fifth, long known as "The Devil's Interval" or "The Devil's Tritone." Iommi didn't know that's what it was, he just used it because "it sounded right."
Critics hated it. They despised it. Most critics have revised those opinions over time, or simply come to grips with the fact that the band Black Sabbath essentially invented the genre. And as with all acts that are both successful and novel, imitators arose that did the same thing. When you chase down other stories of rock and roll bands, you see the veneration they have for who Black Sabbath were.
So I mentioned the hippie craze to highlight the novelty of what they did at the time, but I also mentioned America, and the reason for that is a point Ozzy makes in his book; when he went on an American tour, he was taken aback that the occult elements that were in Black Sabbath's (and his solo career's) shows were taken very seriously by a group of American fans, to the point of being terrifying to him. To him, this was just the stuff of scary movies; to them, they genuinely believed themselves to be followers of Satan.
So on the one hand, you have rock music, which is already critical of certain Christian morality, where the pastors had long been railing against its (in their minds) evil influences already. And then here comes a band that is apparently embracing the evil the pastors have thought was behind rock music all along. And last, you have fans who have essentially gone full Kylo Ren mode, idolizing the evil side even though for the original it was merely a means to an end.
The short version of the above is that rock was never particularly Christian, but all the occult influence can be traced back to Black Sabbath; and for them, it began with a need to change, their enjoyment of horror films, and a fateful and (at the time) highly unusual decision to make the occult part of their band's identity. Because Black Sabbath was both original and successful, they influenced the genre, spawned imitators, and every band in rock that has used occult elements can trace their influences back to them.