As a thundercloud moves through the air, a strong negative charge gathers near its base. Because opposite charges attract, this negative charge is anxious to combine with the positive charges in the ground. Eventually a lightning bolt forms to neutralize these different charges.
We might think that this bolt would want to jump in a straight line; that the electric charge would try to find the most direct route between thundercloud and ground. Why then are lightning bolts so jagged and irregular?
Many Steps
The answer has to do with the complex way a lightning bolt forms. Although it looks like it forms all at once, a lightning bolt is actually produced in many steps. Instead of jumping right to the ground, the cloud's negative charge begins with a short downward hop.
This initial hop is called a "leader," and it's no more than a few hundred feet long. From the lower end of this leader, another leader forms, and from the lower end of this, another. In this manner, the negative charge hops downward from leader to leader like a frog jumping from lily pad to lily pad across a pond.
While this is going on, the ground sends up its own chain of shorter, positively charged leaders. It's only when these two chains meet, about a hundred feet off the ground, that we see the lightning bolt's flash.
The Shape
Lightning is jagged because each leader forms independently of the others. Each place a lightning bolt zigs or zags is where one leader stopped and another one started.
Each place a lightning bolt forks is where two separate leaders formed from the bottom end of a single leader above. This whole process takes only a few thousandths of a second, but that's enough time to sculpt beautiful and complex lightning bolts.