In the summer of 1816, Mary Godwin, her lover Percy Bysshe Shelley, John William Polidori, and Claire Clairmont (Mary’s step-sister) visited Lord Byron in Geneva, Switzerland. It was Byron who proposed that the group write their own supernatural stories and see who could come up with the best one.
Byron wrote only fragments. Polidori really didn’t come up with anything. Mary retired for the evening and had a dream of a corpse that came back to life. Based on that dream she wrote Frankenstein.
There’s a bit of a history surrounding Mary’s dream of a corpse coming back to life. Mary gave birth to a child by Percy in 1815, when he was still married to his first wife, but their daughter, born two months premature, died 11 days later. That incident inspired the back-to-life motif of Frankenstein. Mary Shelley lost three children in all, with only one surviving into adulthood, Percy Florence Shelley. He had no offspring, so there are no direct living descendants of two of the best-known writers of the 1800s.
Frankenstein was written by Mary Shelly. It was published in 1818.