Saluting is a custom which goes back to the days of knights in armor. At that time, the knights raised their visors as a gesture of respect and friendship when greeting someone.
Among soldiers, the custom of raising the right hand to the forehead continued after the helmet and visor were no longer worn.
Our modern-day custom of a man tipping his hat goes back to that custom as well.
Pilots salute each other by tilting, or dipping, their planes’ wings!