We all know what causes thunder and lightning, right?
Two clouds are heading toward each other. They're on a collision course.
They smack into each other making a huge spark and a very loud noise as shown below.
It's super simple. That's all there is to it.
Ok, not really, but I like imagining that's what happens. The truth is almost less interesting. You probably know most of this anyway, but here it is again. I also wanted to make a bunch of pretty pictures.
It's just like any other spark, only on a larger scale. It's the same principle behind a shock, like when you get out of the car and touch the door, or rub your feet in socks on the carpet and then chase your sister.
When you get out of the car or rub your socks on the carpet, the rubbing motion pulls electrons from one surface to another creating an imbalance of charge. Your body has more charges than it should and it's not happy about it (the carpet and car have a lot of charges, so it won't miss the charges as much). The next chance it has to get rid of them, it will, like when you touch the conductive car or your conductive sister.
So, you rub two non conductive things against each other, like socks and carpet, or pants and car seat. These charges can move through your body because it's conductive (that's how iPhone touch screens work) and they can move to other conductive things like metal or other people.
If you shock yourself in a quiet and dark place you'll hear a pop and see a spark. This is the same as lightning.
Clouds end up with unbalanced charges. I don't remember if they end up with positive or negative charges, but it's not too important. I'm going to guess that they're negative, but I don't know for sure. I'm assuming that they get the charges as things rub against each other in the atmosphere. When there are enough unbalanced charges, they want to get away from the cloud. The charges are all trying to get away from each other, resulting in a very unstable and unhappy situation.
The unbalanced charges in the cloud attract the opposite charges in the Earth (again a big thing that won't miss some charges or notice extra ones). It'll pull the opposite charge toward the surface.
Eventually the extra charges in the cloud will make a break for it. They'll rip through the air causing lightning. The sound that accompanies all of the charges breaking off is thunder.
There's a little more nuance to it, like the fact that positive charges don't really move, so a positive charge is created by negatives (electrons) moving away and leaving them unbalanced, but in principle this works. Scientists didn't know which charges were which for years, but the theories still work, so it's not crucial really.
Note: If you want to avoid getting shocked when you get out of the car, grab onto the metal door as you climb out. This way, charges you pick up from rubbing against the seat can move straight to the metal door without the shock. This is something I discovered, so I wouldn't quote me on it.
Disclaimer: I just want to note that all of this came from my memory, so it might not all be totally accurate, but the principle is there.