Saluting by way of presenting arms which have been rendered incapable of causing harm has long been a part of military tradition. Although we now view weaponry salutes as honors proudly bestowed by fighting men upon those of high rank or great achievement, saluting in days long ago was an act of submission — a tangible way of demonstrating that the one performing the action was voluntarily placing himself in the power of the one being saluted. Guns would be emptied a ritual number of times, or sails would be lowered, or spears would be pointed towards the ground, but it all came to the same thing: those carrying out the act were saying "I yield to your authority, and as proof I've just rendered my weapon incapable of being used against you."
Over time the practice evolved into a custom honorary and ceremonial as well as practical. Today's salute is far more a mark of respect than an act of submission.
Cannons became part of weaponry salutes in the 14th century. A just-emptied cannon was a useless piece of ordnance and so made a fine visible display of the lack of hostile intent. Warships took to firing honorary seven-gun salutes, with that number likely chosen for its astrological and biblical significance. Because those crewing cannons on land had access to far greater supplies of powder, they were able to fire three guns (a number chosen for its mystical significance) for every shot fired afloat, making the honorary salute by shore batteries 21 guns.
Eventually, an understanding was reached that the international salute should be established as 21 guns. Although the year 1776 is deeply significant to Americans and the total of its digits does add up to 21, it played no part in this drama. (Indeed, the custom of the 21-gun salute antedates the American Revolution by at least several decades.)
Today, the national salute of 21 guns is fired in honor of a national flag, the sovereign or chief of state of a foreign nation, a member of a reigning royal family, and the President, ex-President, and President-elect of the United States. It is also fired at noon of the day of the funeral of a President, ex-President, or President-elect; Washington's Birthday; Presidents' Day; and the Fourth of July. On Memorial Day, a salute of 21 minute guns (i.e., guns discharged at one-minute intervals) is fired at noon while the flag is flown at half staff.
The 21-gun salute is often confused with the symbolic act of firing three volleys at military funerals, but these are two completely different rituals. The "21-gun salute" is, as the name states, a salute (i.e., an expression of welcome, goodwill, or respect), and in that context the word "gun" refers to naval guns or artillery pieces (typically cannon), not firearms. The firing of three (rifle) volleys at military funerals is technically not a salute but rather a funereal custom, perhaps derived from a superstition of discharging firearms to frighten evil spirits away from the grave, or possibly a recreation of the act of firing three volleys to signal the end of a temporary truce (called to allow each side to clear their dead and wounded from the battlefield). Even when a military funeral detail includes seven members (each of whom fires his rifle a total of three times), this ritualistic act is something distinctly different and separate from the custom of saluting dignitaries by firing 21 guns in their honor.
Cox News Service. "Q&A: Questions and Answers About the News."
St. Petersburg Times. 8 May 1994 (p. A4).