Mary Shelley’s Frankenstein is considered by many to be the first science fiction story. As such, it incorporates some of the scientific research of her day. Shelley probably got her idea for Frankenstein from experiments conducted by scientists such as Luigi Galvani and his nephew Giovanni Aldini.
In the late 1700s and early 1800s human work with electricity was in its infancy. Some of the early experiments looked at the effect of electrical current on the bodies of animals, including human beings. In some cases, electricity was applied to animal cadavers, including those of human beings. These bodies were seen to tremble and move when affected by the current. Some scientists looked into the possibility of reanimating deceased creatures in this way.
Shelley’s husband Percy was a bit of an amateur scientist and conducted his own experiments. It is all but certain that Mary knew about electrical experimentation like the above. This could conceivably have led to her Frankenstein concept.
Ironically, the story itself does not specifically say that electricity had anything to do with bringing the monster to life. Mary implies such by using the word “spark,” but never directly states that electricity is involved. The idea that a bolt of lightning supplied the power that brought Frankenstein’s monster to life is an invention of the movies.
Shelley also stated that prior to writing the story she had a dream that a scientist reanimated a corpse. The fact that she mentions this tells us that it certainly provided some of the motivation for the story.