The phrase "egg on" actually comes from the word "edge", as pushing someone toward the edge means encouraging them to go further.
The spelling of the phrase is due to the fact that "egg on" appeared before English had a standardized spelling; the phrase is likely to have been in use since at least the 1200s.
One early example comes from Thomas Drant's Horace in 1566: "Ile egge them on to speake some thyng, whiche spoken may repent them.".