The popular story about "dead ringer" is vivid, and it is wrong.
It says that frightened Victorians tied a string from the wrist of a buried person to a bell above ground. A watchman would listen overnight, and a ringing bell meant a "dead ringer." Fact-checkers and etymologists reject it. An Australian Associated Press fact-check quotes Word Myths tracing the phrase to late 19th-century horse racing. World Wide Words agrees: the fear of premature burial was real and some bell coffins were built, but the expression has nothing to do with them. The same meme also claims the "graveyard shift" and "saved by the bell," which have unrelated origins.
The evidence points to the racetrack. In American slang, a "ringer" was a better horse secretly entered in a race under a lower class, so that insiders could bet on it. Etymonline gives dead ringer as 1891 and says the phrase preserves that racing sense.
World Wide Words derives "ringer" from the British verb to ring, meaning to substitute something inferior, which it calls a shortening of ring the changes. Etymonline is more cautious. It says the racing sense may come from ring in, "substitute," recorded in 1812, and may pun on ring the changes, a bell-ringing phrase from the 1610s for playing variations on a peal of bells.
So bells are in the story, but only far back, and as a pun. World Wide Words describes the racing sense as US slang that later spread to Britain and was applied to tampered-with vehicles and other objects.
"Dead" is an intensifier. World Wide Words says it was added for emphasis, and a blog on equine etymologies compares it to "dead center," meaning exact. A dead ringer is therefore an exact substitute, a resemblance with no gap at all.
The earliest dates differ by source. Etymonline says 1891, and World Wide Words cites an Ohio newspaper from 1893. Grammarphobia, reporting the OED, finds an earlier example in a Colorado paper of 1878, which calls a knight "a 'dead ringer,' so to speak" for another man. That is already a look-alike sense, so the order of events in the racing story is not settled. An 1882 Manitoba paper uses "ringer" alone, for a horse run under a false name.
The meaning later softened. A ringer in Australian slang came to mean an expert, recorded by 1918, and a dead ringer now means anyone who looks just like someone else.