If air cannot conduct electricity, how can lightning happen?
This is due to the principle of dielectric breakdown. During thunderstorms, the air between the cloud and the ground acts like a capacitor. When the electric field is high enough, the air partially ionizes, at which point there are free electrons to carry current and the air becomes, essentially, conductive.
Air does not conduct electricity in the way that metals do. We normally think of conductors as metals with free electrons that move easily throughout the whole metal. Small voltages move the electrons and a current can flow.
In the case of air and many other materials there are electrons present, but they are firmly bound to individual atoms and molecules and cannot move about the way the free electrons do in metals.
Now if we use a very very high voltage - from about 200 V to 1000 V (or higher) mostly - then we can get sparks formed, lightning or other sorts of plasmas where there are free electrons moving in the gas that can conduct electricity. A significant amount of energy is required to generate these plasmas because electrons from atoms and molecules must be removed against large energy barriers. High voltage is required to drive this 'ionization' process in the gas. Have a look at Paschen's Law and note the Paschen curves showing minimum breakdown voltages for different gases. (Note that energy is required to maintain free electrons in a gaseous environment like air, whereas in a metal conductor the free electrons are always present. Every free electron must be generated by ionization of gas atom/molecule or electron emission from a surface - so for every free electron in the plasma there must have been 5 to 10 eV or more energy used to generate the free electron ... and then electrons will be lost, for example in recombination with positive ions, so energy must be continually used to maintain a significant number of free electrons)
So with large voltages it is possible to generate electrons that can move freely in a gas and conduct electricity - as in the example of lightning.
In addition to the other answers, here is a view on the atomic level.
In the molecules of air, the atoms making up the molecules have valence electrons that bind together to form the molecules. The outer shell is initially not full of electrons but will be full when such atoms "share" electrons.
Electrons can have different energy levels - or energy states. Many very close states make up a band. The band where the valence electrons are, when they are bound in the molecule, is called the valence band.
This band is full. No spaces for more electrons. (The exclusion principle forbids two electrons to occupy the same state, so since all states have an electron, the band is full). No electrons can move from one state to another within this band, since no states are empty. (The exclusion principle also explains why usually only the outer shell is important in reactions - the inner shells are full already.)
Now, if one electron can jump up in energy level - all the way up to another band - then in this new band, all the other states are free and unoccupied. This electron can move almost freely around from state to state within this band, and almost no force or energy is needed to move it around. This band is called the conduction band.
If there are electrons in the conduction band, this material can conduct current.
- Very good conductors have a conduction band and a valence band that almost overlaps.
- Very good insulators have bands far from each other - there is a large band gap in between.
For electrons to move up to the conduction band in an insulating material, they need to be added enough energy equal to the band gap $E_g$ to move up there. As far as I remember, the energy gap is at about $5 \:\mathrm{eV}$ for a usual insulator to move one electron up there. This is a large amount of energy, that only rarely is applied; e.g. in a thunderstorm where huge potential differences are created.
Then electrons are moved up and "freed" from their fixed positions with the atom. The atoms are now ionized. Then lightning can happen in an insulator like air that suddenly becomes conducting.