Salute by gunfire is an ancient ceremony. The British for years compelled weaker nations to render the first salute; but in time, international practice compelled "gun for gun" on the principle of equality of nations. In the earliest days, seven guns was the recognized British national salute because seven was the standard number of weapons on a vessel. In that day, gunpowder made from sodium nitrate was easier to keep on dry land than at sea. Thus those early regulations stated that although a ship would fire only seven guns, the forts ashore would fire two shots to each one shot afloat, hence the number 21.
The system of odd numbered rounds is said to have been originated by Samuel Pepys, Secretary to the Navy in the Restoration, as a way of economizing on the use of powder, the rule until that time having been that all guns had to be fired. Odd numbers were chosen, as even numbers indicated a death.
With the increase in quality of naval gunpowder, by the use of potassium nitrate, honors rendered at sea were increased to the shore salute. 21 guns became the highest national honor, although for a period of time, monarchies received more guns than republics. Eventually republics gained equality in Britain's eyes.
There was much confusion because of the varying customs of maritime states, but finally the British government proposed to the United States a regulation that provided for "salutes to be returned gun for gun." The British at that time officially considered the international salute to sovereign states to be 21 guns, and the United States adopted the 21 guns and "gun for gun" return on 18 August 1875.