###As far as I can tell, the D&D Gnomes are somewhat of a hybrid between Gnomes and Nisse (the "inspiration" for Garden Gnomes)
As far as I can tell, the D&D Gnomes are somewhat of a hybrid between Gnomes and Nisse (the "inspiration" for Garden Gnomes)
D&D actually has a surprising level of research and ancient, somewhat-obscure mythologies behind it, as can be seen from the Gorgon in this answer.
The earliest forms of gnomes called as-such (well, technically they were called "genomos", but it's close) are thought to date from the 16th century, featuring in Ex Libro de Nymphis, Sylvanis, Pygmaeis, Salamandris et Gigantibus, by the Swiss scholar Paracelsus. They are a form of Earth Elemental that manifests as a small, human-like figure, about two "spans" (one cubit) tall, and can move through solid earth like it was air.[2]
Gnomes really became popular during the 18th Century in fairy tales, where they were typically depicted as the benevolent and ingenious guardians of treasures and mines. Nicolas-Pierre-Henri de Montfaucon de Villars, the Abbot of the town of Villars, France, and who was the source for Alexander Pope's The Rape of the Lock, describes gnomes in this way[3]:
"The Earth is filled almost to the Center with Gnomes or Pharyes, a People of small Stature, the Guardians of Treasures, of Mines, and of Precious Stones. They are Ingenious, Friends of Men, and easie to be commandded [sic]."
This is likely where the D&D source for gnomes comes from: inventive, benevolent creatures who enjoy gems ("Precious Stones") as well as their procurement.
Meanwhile, it is also interesting to note that Garden Gnomes are derived from the Scandinavian Nisse/Tomte/Tomtenisse, which is an ancestral farming spirit which ranges from a few inches to half the height of a human (or almost analogous to their size in D&D, 3-4 feet high), but the Nisse itself is more like a winter version of a Gnome than what a Garden Gnome is.
Overall, I suspect that the D&D version of Gnomes combines several aspects of gnomes from history into one type of creature.
This was actually a fun question to research for, thank you.
(1 is in-use by the link for Gorgons)
[2]Lewis, C. S. (1964). The Discarded Image - An Introduction to Medieval and Renaissance Literature. Cambridge University Press. p. 135. ISBN 0-521-47735-2.
[3] Montfaucon de Villars, Nicolas-Pierre-Henri (1680). The Count of Gabalis: Or, The Extravagant Mysteries of the Cabalists, Exposed in Five Pleasant Discourses on the Secret Sciences. Translated by Gent, P. A. London: B. M. Printer. pp. 29–30. OCLC 992499594.