I mean particularly swords and sorcery fiction. You see them everywhere from Conan to Fafhrd and the Grey Mouser, and even superhero comics. It seems like every other evil cult from the 30's to the 60's worshipped some sort of snake deity, or deity in the form of a snake. And it feels like, since the 80's, there hasn't been a lot of them either in superhero fiction or fantasy fiction, barring traditional tabletop RPGs that draw inspiration from these earlier swords and sorcery stories.
Does this reflect something particular about the time? Or is it just because snakes are a symbol of skullduggery?
There are three main influences on snake-cults in popular literature in the early 20th-century onward:
In various religions, there are genuine mythological creatures, spirits, deities, or other prominent figures that are modeled on snakes or have snake-like attributes. Some of these include Damballa from Haitian Vodou, or Quetzalcoatl of ancient Aztec religion. These serpentine figures gained greater prominence in 20th century literature thanks to publications like The Magic Island (1929) by William Seabrook, which helped popularize the idea of "zombies" and voodoo through Hollywood films like White Zombie (1931), and was a sourcebook for many pulp stories like Robert Bloch's "Mother of Serpents" in Weird Tales Dec 1936.
The great dragon was thrown down, that ancient serpent, who is called the Devil and Satan, the deceiver of the whole world—he was thrown down to the earth, and his angels were thrown down with him.
Serpents were generally given a negative portrayal in the Bible from Genesis through Revelation, and in popular art and literature the metaphor of the serpent for Satan was well understood, especially after the 2nd and 3rd Great Awakening in the United States which increased general Bible literacy. This allowed many Christian readers and writers to evaluate pagan or non-Christian serpent-worship as essentially (if not explicitly) Satanic in nature. Ignoring the attributes that the adherents actually attributed to these beings, many pulp authors would turn snake-figures into malevolent devils by default. E.g.
Sometimes I would get up early and go to church myself on a weekday morning, along the soft roads through the pre-dawn dusk along with scores of soft-stepping, barefooted Blacks, plodding to church in the early dawn, going to get strength, power, to fight the age-long battle between God and Satan—the Snake—here where the sons of Ham tremble beneath the lingering fears of that primeval curse which came upon their ancestor because he dared to laugh at his father Noah.
- Henry S. Whitehead, "Black Terror" in Weird Tales Oct 1931
For my part, I am too little versed in antiquities to even offer an opinion, but I am inclined to think that these figures represent a pre Christian age and have some phallic significance. I am especially inclined to this view by the consistent use of triangles in the stone figure. Phallic worship was very common in Ireland, as you know—the legend of Saint Patrick and the snakes being symbolical of the driving out of the cult—and in almost every locality where phallic worship thrived, small images representing the cult have been found, in such widely scattered places as Africa, India and Mexico. Though of course the workmanship of the images differs with the locality and I have never seen or heard of, figures just like these of your’s. At any rate, they are fascinating and open up enormous fields of dramatic conjecture. I am sure you could build some magnificent tales out of them.
- Robert E. Howard to H. P. Lovecraft, c. Oct 1930, A Means to Freedom 1.87
The same anthropological and spiritual curiosity that led to greater interest in mythology, Christianity, and non-Christian religions in the late 19th/early 20th century coincided with a rising academic interest in sex, psychology, and a practice called euhemerism where investigators sought to rationally interpret the origins of various myths, legends, and folktales - the most prominent example of that being The Golden Bough (1890) by James Frazer.
Robert E. Howard is known to have owned a book called Sex and Sex Worship (1922) by Otto Wall; one of the ideas he derived is the supposition (not unique to Wall) that the "serpent cults" of antiquity or paganism were really worshiping the principle of masculine sexuality (i.e. snake = penis). There is some basis for this - the Hindu term kundalini (coiled snake) for creative and sexual power accessed or manipulated through tantric yoga entered Western occultism through the works of Aleister Crowley and others - but for the most part, this was again, Western audiences imposing their own concepts and values on other cultures.
A lot of these individual elements could come together, since Satan was often associated with sexuality as well - but those are the three main drivers for why you would see the popularity of snake-cults in pop fiction in the early 20th century on down.
...but that's not the entire story.
Pulp writer Robert E. Howard absorbed all of these influences over his life, and they found expression in his fiction in various ways. Most notably, he had a tendency to set up snakes, snake-people, and snake-cults as antagonists in his fantasy work. This ties in to a lot of different anthropological and literary influences during the 1930s, and if you want to read about it in detail you can check out Conan and the Little People: Robert E. Howard and Lovecraft's Theory - it's a long read, but it shows some of the development of the idea.
Of particular interest to sword & sorcery however is the Serpent-God Set, which Robert E. Howard created for the first Conan the Cimmerian story "The Phoenix on the Sword" in Weird Tales Dec 1932:
The steps were carven each with the abhorrent figure of the Old Serpent, Set, so that at each step he planted his heel on the head of the Snake, as it was intended from old times.
Howard had created serpent-people and serpents as antagonists before this, but this is the first time he created an actual named serpent-deity, though the idea goes far back in his writing. The Conan stories were set in the Hyborian Age, long before known history, and Set was the god of the Stygians - a precursor people to the Egyptians.
The problem is, the Egyptian god Set or Seth or Sutekh is not a serpent-god - but Howard's creation was so popular, that Set was often adopted as an Egyptian serpent-god in other media. This can most clearly be seen in the Egyptian vampire-cult called the Followers of Set in Vampire: the Masquerade, and in Marvel comics where the serpent-god Set was adopted into the Marvel universe thanks in part to Marvel's licensing of Robert E. Howard's Conan in the 1970s-2000s.
Now, this doesn't mean every single serpent-cult in popular fiction owes itself to Robert E. Howard. H. P. Lovecraft, for instance, created the serpent-deity Yig, "The Father of Serpents" out of whole cloth for "The Curse of Yig" in Weird Tales Nov 1929, and Bram Stoker's "The Lair of the White Worm" (1911) is a fictional development of the legend of the Lambton worm - and the snake-like vampires in the 1988 film based on Stoker's story were another inspiration for the Followers of Set in Vampire: the Masquerade.
So, lot of different influences in popular culture, some independent and some working with each other. Roleplaying games like Dungeons & Dragons borrow or take inspiration quite heavily from Robert E. Howard, H. P. Lovecraft, and Fritz Leiber, and their snaky gods and cults owe something to their pulp roots.