Because air is a very low density material, there are not a lot of atoms per unit volume to engage in heat transfer type collisions, and if the air is trapped and therefore motionless, it does not carry heat away with it by moving to another location.
I presume that you are referring to thermal insulation and not electrical. Whilst air is a good insulator there are other gases that are more effective. Check out the gases used for filling double glazing units, this will give you a clue as to what makes a good insulating gas.