c. 1200 as a call implying challenge, rebuttal, anger, derision; variously spelled in Middle English hei, hai, ai, he, heh. Later in Middle English expressing sorrow, or concern; also a shout of encouragement to hunting dogs. Possibly a natural expression (compare Roman eho, Greek eia, German hei, Old French hay, French eh). In modern use often weakened, expressing pleasure, surprise.
Þa onswerede þe an swiðe prudeliche, `Hei! hwuch wis read of se icudd keiser!' ["St. Katherine of Alexandria," c. 1200]
In Latin, hei was a cry of grief or fear; but heia, eia was an interjection denoting joy.