Gunpowder was a by-product of the search for immortality.
Daoist alchemists in Tang-era China were mixing substances for an elixir of life. The first relevant recipe appears in a text of 808, the first full gunpowder formula in the military manual Wujing Zongyao of 1040 to 1044. The Chinese name huoyao still means literally "fire medicine".
Useful: Research goals and research results often have little to do with each other.
Source: en.wikipedia.org