The first erratic things in English were in the sky. In Middle English an erratik sterre, a "wandering star," meant a planet.
The word comes from Latin erraticus. Merriam-Webster glosses it as "having no fixed position, wandering," used of a heavenly body. It was built from the verb errare, "to wander." Merriam-Webster describes the ancient planets as bodies with motions of their own among the fixed stars. The word planet itself goes back to Greek planēs, literally "wanderer."
Errare had a second meaning that English also kept. Dictionary.com glosses it as "to make a mistake, err." To wander off course and to go wrong were the same idea in Latin. That is why erratic sits beside err and error in the dictionary.
Merriam-Webster dates the adjective to the 14th century, in the sense "having no fixed course," as in an erratic comet. Later senses moved from motion to behavior. Erratic came to mean lacking consistency, like erratic hours, and then eccentric, as in an erratic genius.
Geology gave the word its most solid meaning. A glacial erratic is a rock carried by glacier ice and dropped where the local bedrock is different. Erratics range from pebbles to huge boulders, and some have traveled hundreds of kilometers.
For a long time they were a puzzle. In the 18th century people took them as evidence of the biblical flood. Goethe was among those who studied the glaciers of the Alps. Two of those naturalists, Jean de Charpentier and Karl Schimper, concluded that glaciers had moved Alpine blocks onto the Jura Mountains. Charles Lyell described erratics in modern terms in 1830, and Louis Agassiz went on to propose a past ice age.
Some erratics are famous. Big Rock near Okotoks, Alberta, weighs about 16,500 metric tons. Plymouth Rock in Massachusetts, the traditional landing place of the Pilgrims in 1620, is also listed as one.
So the erratic boulder and the erratic planet share a word. One wanders across the sky; the other wandered across a continent on a sheet of ice.