It has been said that the gesture began in medieval times. When approaching a senior officer a man would lift his helmet visor so that he could be recognised, the hand moving in a similar way to the modern salute. Unfortunately for this neat idea, the modern form of salute is not recorded before the early 18th century.
The salute probably developed in response to a change in military headgear. After metal helmets fell out of favour, soldiers wore hats similar to those of civilians. Like civilians they raised their hats when greeting a superior.
By 1700 grenadiers were wearing tall, conical hats held in place with secure chinstraps that were difficult to raise in greeting. The men began to merely touch their hats as if intending
to raise them. Soon other soldiers adopted the shako, busby or bearskin, all of which were held in place by a chinstrap. They, too, stopped raising the hat and instead merely touched
its brim. This action was formalised as the salute in European armies by about 1780, and from them spread to the rest of the world.
Answered by: Rupert Matthews, historian and author