When did the term "Earthling" come from?
Though people associate it with very old science fiction, you won't see any occurrence of the term in its current meaning (a human inhabitant of the planet Earth, as opposed to an extraterrestrial) prior to 1949.
Actually, the term was first used by the Old Man himself, Robert E. Heinlein, in his 1949 novel "Red Planet" (a novel remembered for a weird digression where they explain the ethics of adults responsibly allowing children to carry loaded firearms). This all the way back when the Old Man was not quite so old yet, when RAH was actually a hotshot young lion looking to make a name for himself in the pages of the greatest scifi pulp of them all, Astounding Science Fiction under John W. Campbell, right at the dawn of the Golden Age of Science Fiction.
Heinlein created the term Earthling and used it in a lot of his work instead of human because it was very important to distinguish in his stories between humans from Earth and, say, colonists of human stock from Mars, like in Podkayne of Mars. Hello, Mars used another interesting term with the same origin, where humans born in space referred to humans that lived their entire life on earth (semi-derogatorily) as "groundhogs."
The term caught on because Heinlein used it in his juveniles (what today we'd call "young adult" books), and to every generation prior to the Millennials, Heinlein was THE science fiction writer, much like how Agatha Christie is THE mystery author. It's a strange irony that, now that young adult books run the world, the young adult scifi author has mostly vanished from prominence.
Prior to 1949, scifi writers used a lot of other variant terms for humans from Earth. E.E. Smith, who Heinlein admired and listed as his single biggest influence (and from who Heinlein got the idea of space marines in power armor, an idea the Old Man used in Starship Troopers), used the term Tellurian to refer to humans from Earth in the Lensman novels, as Earth in his future era was known as Tellus, an erudite term for a god of Earth in Greek Myth used in Hamlet. Humanoids in the Lensman series were known as "Tellus-type lifeforms."
(You know, I feel like Tellurian for human and Tellus for Planet Earth should make a comeback.)
That said, where did the term Earthling come from originally? The Old Man didn't make it up. "Earthling" is an old term going back to Old English and predated the modern English language. It came from eorþe (earth) and yrþling (farmer). The term yrþling (ling) literally means farmer, but since that was the most common occupation in the old days, "earthling" acquired a secondary meaning to just refer to a person, a mortal human in general, a meaning similar to "guy," "dude," or "fella." And -ling also became a suffix to indicate a noun or person, same as terms like "hireling" and "underling" and "weakling."