Lightning is a flash of light created by electric discharge. It is extremely bright for a brief moment in time even at great distances. You have probably seen static electricity where you see a small spark. Lightning is similar except of course on a much bigger scale. Lightning requires a big vertically developing cloud complex. A cloud that produces lightning will tend to also have rain falling out of it. The precipitation process within a cloud is a reason lightning occurs. As ice and water develop in clouds there is an electrical buildup. The electrical buildup on each ice and water drop is very small but the huge number of ice crystals and water drops creates a large electrical difference between different portions of the cloud. Lightning occurs to balance the electrical build in the clouds or between the clouds and the ground.
Thunder is created by a rapid expansion of air. Think of a balloon popping. There is a sudden release of noise due to the rapid expansion of air. When lightning moves through the air it increases the temperature of the air dramatically in a very short period of time. The air then cools rapidly. This rapid expansion and contraction of the air gives off the sound waves that is heard from the lightning.
Lightning is very dangerous. Make sure to stay inside when there is lightning.