Gunpowder was an accident of the search for eternal life
Chinese alchemists hunting for an elixir of immortality kept mixing sulfur, saltpeter and other ingredients, and one ninth-century Daoist text warns that such experiments burned people's hands and faces and even whole workshops. The result still carries its origin in its Chinese name: huoyao, fire medicine.
Black powder combines three ingredients: sulfur and charcoal as fuel, and potassium nitrate, or saltpeter, supplying oxygen. The first confirmed formula appears in a Tang dynasty text of 808, calling for six parts sulfur, six parts saltpeter and one part birthwort herb. Chinese alchemists already knew saltpeter well; a text from 492 notes it burns with a purple flame, a handy test for purity that predates any Latin account of refining it by about seven centuries. Armies first used the mixture around AD 904, and it counts among China's Four Great Inventions.
Chemists call it a low explosive because it deflagrates, burning faster than paper but below the speed of sound, rather than detonating with a supersonic shock. That makes it a good propellant: it builds enough pressure to drive a ball out of a barrel without bursting the gun. It is weaker at shattering things unless tightly confined, though it filled artillery shells until high explosives arrived in the later nineteenth century.
It is also messy. Less than half its mass becomes gas; the rest ends up as smoke that fogs a battlefield and reveals a shooter's position, or as soot that clogs barrels and jams automatic weapons. The residue absorbs moisture and forms corrosive hydroxides that eat iron and steel, so black powder guns need frequent cleaning. Smokeless powder has replaced it in most weapons, and dynamite and ammonium nitrate mixtures have taken over most industrial blasting.
Gentleness keeps it in work. Because it cracks rock less violently than high explosives, quarries use it for fragile slate and for monumental granite and marble, yielding more usable stone. It lifts fireworks shells, powers blank rounds and signal flares, and fires rescue lines.
Source: Gunpowder