According to the Tur (OC 4:1), the reason that we wash our hands in the morning is because of the "evil spirit" (רוח רעה) that had settled on them during the night. Is this custom referenced prior to the Tur? What is its origin? I'm guessing that it's not mentioned in the gemara, since the Bet Yosef doesn't bring a source.
The Gemara Shabbos (108b / 109a, I think it depends on your print) says that one should not touch certain areas of your body (with the hands) in the morning when you wake up (like the mouth) unless you first wash your hands. The reason given there is because of the ruach ra'ah (evil spirit) that rests on the hands before washing. The remedy given is to wash the hands three times alternating each hand.
The Zohar (I 184:2) discusses the reasoning for this. When a person sleeps, they experience a taste of death. This evil spirit then rests on the person. When they awaken and the soul returns, the evil spirit remains just on the end of the hands.
Poskim from the Rishonim until our times debate if this evil spirit does not exist today at all, or it does exist in a limited version, or it exists just as it existed as mentioned in earlier tradition. There are various Halachic ramifications.