Lightning is basically static electricity caused by huge concentrations of raindrops rubbing against each other high up in the sky.
Lightning and thunder happen simultaneously, but lightning travels near the speed of light while thunder moves at the speed of sound, approximately 866,000 times slower than the speed of light, which explains the delay between the two phenomena.