Click http://www.worldwidewords.org/qa/qa-pul2.htm for an answer from a noted etymologist and lexicographer.
Waving appears to be virtually universal, so any prospect of finding out when and why it originated is pretty remote. If it was really "Goodbye" - ie probably never to return - the raised hand might conceivably have represented a protection over the head of the one leaving...a sort of divine umbrella.