Gunpowder is a highly combustible substance that can be lit on fire and exploded. After lighting, the player will have 3-6 seconds to escape the blast radius. The explosion will do 200 damage and can knock down structures. The damage is substantial enough to kill most unarmored players so it is important to be careful.
Despite being introduced well before caves, the best use of gunpowder is in caves. Explosions in caves cause minor earthquakes which can dislodge things from the ceiling, including rocks and other minerals. This makes most minerals renewable.