People originally shook hands to check for concealed weapons
The handshake is thought to have originated as a gesture of peace by demonstrating that the hand holds no weapon.
Some even suggest that the up-and-down motion of the handshake was supposed to dislodge any knives or daggers that might be hidden up a sleeve.
http://www.history.com/news/ask-history/what-is-the-origin-of-the-handshake