Old English onforan "before, at the beginning of, in front of," from phrase on foran, from on (prep.) + foran (adv.) "in front," dative of for.
In some cases probably it represents Old English ætforan "at-fore." Once the literary equivalent of before, now it has mostly been replaced by that word except in nautical use and in combinations such as aforesaid and aforethought.