The electricity that causes lightning is generated in a storm cloud. There are winds that blow inside a storm cloud. They cause the dust and ice particles inside the cloud to rub together. This rubbing causes static electricity to build up just like it does when you rub a balloon on your sleeve. Some of the electricity is positive and some negative. A spark jumps between positive and negative.
The static electricity in a storm cloud gets stronger and stronger until the cloud can no longer hold it. When this happens the electricity escapes as a flash of lightning. It make a zigzag path through the air. If the lightning passes from one cloud to another you cannot see its path but the clouds light up. This is called sheet lightning. If the lightning passes from a cloud to the ground you can see the path and this is called forked lightning.
A lightning flash may be charged at up to 100 million volts. As the electricity flows, it heats the air and makes it expand rapidly. The expanding air makes the roaring sound we call thunder.