The custom of setting firecrackers, was a traditional practice to frighten the "年兽" beast. Legend has it this creature terrorized the villagers and pillage their crops all year round.:(
The only way to ensure they made it thru the year safely "过年", is to repel this beast with fireworks.
Failure to do so, means you would risk losing your harvest, or worst to get eaten up by the beast!