In 18th England they started running out of places to bury people. Consequently, people would dig up coffins and take the bones to a ‘bone-house’ and reuse the grave. When reopening these coffins, 1 out of 25 coffins were found to have scratch marks on the inside and they realized they had been burying people alive. So they clergy decreed that they should tie a string on the wrist of the corpse, lead it through the coffin and up through the ground and tie it to a bell. Someone would have to sit out in the graveyard all night (the ‘graveyard shift’) to listen for the bell.
Thus, someone could be ‘saved by the bell’. Also they could be considered a ‘dead ringer.’