"You fear to go into those mines. The dwarves delved too greedily and too deep"
In European folklore dwarves are often associated with mines and underground treasures, a myth also popularized by author J. R. R. Tolkien (1892-1973) with his underground city of Khazad-dûm - the Delving of the Dwarves, a mining complex made by the small people of Middle-earth digging for precious metals and gemstones.
Fig.1. Dwarves are traditional symbols for the mining industry, here on the cover of a textbook on mining technologies from 1898 (BERSCH, W. Mit Schlägel und Eisen. eine Schilderung des Bergbaus und seiner technischen Hilfsmittel), image in public domain.
Maybe this myth was inspired by real mining activities. Medieval miners had to rely on hammer and chisel and it was necessary to maintain the sections of the galleries as small as possible. Small miners would have an advantage in these galleries (unfortunately there are no reliable measurements of medieval miners to support this hypothesis).
Fig.2. Medieval prospecting shaft in ore-bearing prasinitic rocks - did these pits inspire the myth of a race of small people living underground?
Apart the small size, another characteristic attribute of dwarves - the strange hat - shows a striking resemblance with the Phrygian caps, often worn by ancient miners as sort of protective headgear.
Fig.3. Miners wearing Phrygian caps, from GAETZSCHMANN, M.F. (1856): Die Auf- und Untersuchung von Lagerstätten nutzbarer Mineralien (image in public domain).
Even if based in reality, the true origin-story oft the dwarf as character in ancient and modern lore seems to be lost forever.