Mary Shelley conjured up images of a reanimated corpse in her novel Frankenstein, published in 1818. While the novel was light on the technical aspects, it explored the ethics of a "successful" reanimation experiment. She was not the first to consider the possibility. Scientists and pseudoscientists were experimenting with electricity and its effect on flesh for decades already. After it became known that electricity could make the muscles of dead animals, the effect was even used for entertainment.
People outside of science were also fascinated by electricity. They would attend shows where bull heads and pigs were electrified, and watch public dissections at research institutions such as the Company of Surgeons in England, which later became the Royal College of Surgeons.
When scientists tired of testing animals, they turned to corpses, particularly corpses of murderers. In 1751, England passed the Murder Act, which allowed the bodies of executed murderers to be used for experimentation. “The reasons the Murder Act came about were twofold: there weren’t enough bodies for anatomists, and it was seen as a further punishment for the murderer,” says Burba. “It was considered additional punishment to have your body dissected.”
Atlas Obscura tells the tale of a particularly gruesome 1818 experiment in which Scottish chemist Andrew Ure attempted to bring an executed convict's body back to life. Maybe he should have read Shelley's novel first.