exclamation of greeting, 1862, American English (first recorded reference is to speech of a Kansas Indian), originally to attract attention (15c.), probably a variant of Middle English hy, hey (late 15c.) which also was an exclamation to call attention. The only definition in the "Century Dictionary" [1902] is "An exclamation of surprise, admiration, etc.: often used ironically and in derision," suggesting the development as a greeting-word mostly took place early 20c.
Even more informal is the widely used 'Hi.' A friendly greeting for people who already know each other, it should never be said in answer to a formal introduction, but it is universally used, and accepted, by the young. ["The New Emily Post's Etiquette," 1922]
Extended form hiya attested from 1940.