According to americanpyro.com, “many historians believe that fireworks originally were developed in the second century B.C. in ancient Liuyang, China. It is believed that the first natural "firecrackers" were bamboo stalks that when thrown in a fire, would explode with a bang because of the overheating of the hollow air pockets in the bamboo.
The Chinese believed these natural "firecrackers" would ward off evil spirits.
A kind of magic spell.
Wikipedia goes even further: “Chinese people originally believed that the fireworks could expel evil spirts and bring about luck and happiness.” A kind of good luck charm, when you think about it.