Old English beforan "in front of, in former times; in the presence of, in front of in time or position," from Proto-Germanic *bi- "by" (see by) + *forana "from the front," adverbial derivative of *fora (from PIE root *per- (1) "forward," hence "in front of, before"). Compare Old Frisian bifara, Old Saxon biforan, Old High German bifora, German bevor.
As a conjunction, "previous to the time when," from c. 1200. Contrasting before and after in illustrations is from Hogarth (1768). Before the mast in old sailing ship jargon in reference to the life of a common sailor is from the place of their berths, in front of the fore-mast.