In Medieval times stonemasons travelled the country looking for work. Most people didn’t read or write so they needed a way to prove that they had passed the rigorous apprenticeship to become a properly qualified craftsman.
When you qualified as a master stonemason you were given special words and gestures that only another stonemason of that qualification would know. So it is how your professional qualifications could be checked; a bit like a Medieval ‘chip and pin’ system.
Freemasonry borrows the traditions of stonemasons, so along with the tools and apron it adopted the idea of a symbolic handshake. The handshake, or ‘grip’ as a freemason would call it, varies with each of the three degrees. Just like with the qualification level of a stonemason, it allows you to confirm during the meeting that you’ve passed one or more of those ceremonial levels.
The special handshake was very important in the past. If you were a freemason who travelled you would want to prove you were really a member at a new lodge. Today it is purely traditional and reminds freemasons of their symbolic link to those Medieval craftsmen every time they share it.