When electricity is given off through lightning, it heats the air in its path. This heating makes the air expand quickly and often violently.
The molecules of heated air fly around in all directions and collide with cooler, distant air. This collision sets up a “wave” of noisy, rumbling air called thunder.