The solar wind carries both positive and negative ions. Earth's magnetic poles drop electrons to the North pole, and positive charges (ions, nucleii) preferentially to the South pole (one of the reasons the South pole has an ozone hole in its winter). This makes for a charge separation in and through the Earth and the atmosphere. There is a net charge difference between the Earth's surface and "the atmosphere", and this is many billions (if not trillions) of volts. Water as vapor is pretty much in equilibrium with the distributed charge in the air around it. As it coalesces into larger and larger droplets, the net charge disperses over the surface and the droplet has a significantly different charge than the surrounding air (if not the cloud the droplet is now probably a part of). As the now-charged cloud moves over the surface of the Earth, opposite charges follow it through the Earth itself. Rain has a huge volume but a much smaller surface area than the vapor, and so the entire cloud must carry the extra charge. Lots of charge that really "needs" to be somewhere else. A force that is potentially orders of magnitude stronger than gravity... looking for a place to go... At some point, the charge difference is enough that even a single cosmic ray can initiate lightning to follow its ionization path, either ground-to-sky or sky-to-ground, and primarily only electrons make the trip either way... too much acceleration and energy required to move heavy charged nucleii over the whole path. Thunder is caused by the flow of electrons superheating the atmosphere in its path to a conductive state... a plasma, which is much hotter, less dense, but much "larger" that the air before the arc. So thunder is a shock wave or "sonic boom" of air being blown out of the way of the speeding electrons.