According to the Oxford English Dictionary, the first published use of hello was in 1827. However, back then, it wasn't used mainly as a greeting.
Instead, hello was used either to get someone's attention (“Hello, what's going on here?") or to show surprise (“Hello, what happened here?"). This early usage may stem from the fact that hello probably developed from words in Old High German (hallo and hollo, meaning “to fetch" and shouted during a hunt when prey was spotted) and French (holla or hola, meaning “whoa there!").
The exact origins of hello are not clear, though. There are a few other ideas about where hello might have come from. Some believe hello came from hullo, which was a British word used to draw attention, express surprise or greet another.