Lightning and thunder storms are a wonder of nature to some and an absolute terror to others. Though a fascinating phenomenon, lightning storms are probably what you'd imagine a clash between the gods would sound like, the rumbling of massive immortals battling in the heavens. It's not terribly pleasant.
But what causes lightning and the accompanying thunder? How do these two things wind up together? Fulminologists (scientists who specifically study lightning) aren't one hundred percent sure even today, as studying lightning formation is rather difficult. Thunderstorms can appear so quickly and so violently, not to mention so unpredictably, that the chances of getting accurate readings may be as high as getting struck by lightning in the first place. But we can at least look at what they've hypothesized happens during a lightning storm.
Though lightning can appear without an accompanying rainstorm, the phenomenon typically begins with the kicking-in of the water cycle. Heat from the sun, or some other man-made source, heats up the Earth and causes moisture on the ground - lakes, rivers, streams, what have you - to partially evaporate, turning the water molecules into a gas that travels upward.
As that water vapor leaves the heated ground it reaches the cooler, upper layers of the sky, where the cooling effect causes the vapor to slowly but surely change back into water droplets. This forms both clouds and the rain that pours down from those clouds.
Now the science gets a bit hazy, and fulminologists argue over what happens next. It's generally agreed that lightning is formed when the water molecules in the air interact with ice crystals found in the clouds. The interaction between the two - sometimes considered 'friction', though not always - causes a build up of either a positive or a negative charge. Eventually this charge must be dispersed from the cloud, and is sent out via a bolt of lightning. This lightning can either strike other atmospheric elements or travel down to the ground, seeking out oppositely-charged objects.
The thunder is more easily explained. Regardless of the process by which lightning is generated, it manages to produce a massive amount of heat that supercharges the air around it. This air then rapidly expands, generating a large, noisy shock wave that manifests itself, seconds later, as thunder. Because the speed of light is faster than the speed of sound the lightning strike is always seen before thunder is heard, and indeed the thunder may not be heard at all if the lightning strike is far enough away.
To say that these principles are hard set in stone is difficult, of course, because it's extremely difficult to measure lightning strikes. What should be understood, at least, is that lightning is extremely dangerous and should be avoided at all costs. Stay indoors during lightning storms.