Middle English for-, fore-, from Old English fore-, often for- or foran-, from fore (adv. & prep.), which was used as a prefix in Old English as in other Germanic languages with a sense of "before in time, rank, position," etc., or designating the front part or earliest time.
Old English grund "bottom; foundation; surface of the earth," also "abyss, Hell," and "bottom of the sea" (a sense preserved in run aground), from Proto-Germanic *grundu-, which seems to have meant "deep place" (source also of Old Frisian, Old Saxon, Danish, Swedish grund, Dutch grond, Old High German grunt, German Grund "ground, soil, bottom;" Old Norse grunn "a shallow place," grund "field, plain," grunnr "bottom"). No known cognates outside Germanic.
Sense of "reason, motive" first attested c. 1200. Meaning "source, origin, cause" is from c. 1400. Electrical sense "connection with the earth" is from 1870 (in telegraphy). Meaning "place where one takes position" is from 1610s; hence stand (one's) ground (1707). To run to ground in fox-hunting is from 1779. Ground rule (1890) originally was a rule designed for a specific playing field (ground or grounds in this sense attested by 1718); by 1953 it had come to mean "a basic rule."
<a href="https://www.etymonline.com/word/foreground">Etymology of foreground by etymonline</a>
Harper, D. (n.d.). Etymology of foreground. Online Etymology Dictionary. Retrieved $(datetime), from https://www.etymonline.com/word/foreground