Most words have no known inventor. Doppelgänger has one, and he explained his new word in a footnote.
The German novelist Jean Paul published Siebenkäs in Berlin, in three volumes, in 1796 and 1797. Its hero, Firmian Stanislaus Siebenkäs, is unhappily married. His friend Leibgeber, a lookalike who serves as his alter ego, talks him into faking his own death to start a new life.
To describe such a double, Jean Paul made up a word. He spelled it Doppeltgänger and added a footnote: "So heißen Leute, die sich selber sehen." That translates as "the name for people who see themselves." Wikipedia calls Siebenkäs the first novel in which a lookalike is described this way.
There is an odd twist. Atlas Obscura says Jean Paul also used Doppelgänger, without the "t," for something else entirely: a meal with two courses served at the same time. The distinction did not last, and the spelling without the "t" took over the ghostly meaning.
The parts are simple. Doppel means double, and a Gänger is one who goes, so the literal sense is "double-goer." Etymonline notes that it arrived with a ghostly sense: the apparition of a living person.
The idea is far older than the word. Atlas Obscura points to the ancient Egyptian ka, an aspect of the soul pictured as a spirit identical to the body. The Norse vardøger was milder, a double that arrived somewhere before the person did. In folklore, Wikipedia says, meeting your own double was usually taken as an omen of bad luck, often of death.
Famous people claimed to have met theirs. Goethe described passing his double on horseback in the early 1770s. Percy Bysshe Shelley told his wife Mary he had met his own shortly before he drowned in 1822. Soon after his election in 1860, Abraham Lincoln saw his face doubled in a mirror, one reflection ghostly pale.
English took the word within a few decades. Etymonline finds it as a German word in English by 1824, and as English by 1826. Spellings wandered at first. Grammarphobia cites Walter Scott's "double-ganger" from 1830, and "dopple-gangers" in 1851.
Today it usually means a stranger who looks just like you, no ghost required. English dictionaries accept it with or without the umlaut.