I am not sure what causes gas molecules to be invisible.This question may look silly but I really want to know the story behind it.
(photograph credit: Efram Goldberg)
[Note: left-most ampule is cooled to -196°C and covered by a white layer of frost.]
$NO_2$ is a good example of a colorful gas. $N_2O_4$ (colorless) exists in equillibrium with $NO_2$. At lower temperature (left in Wikipedia photo), $N_2O_4$ is favored, while at higher temperature $NO_2$ is favored.
For a gas to have color, there needs to be an electronic transition corresponding to the energy of visible light.
A complete analysis of how visible or invisible a gas is would consider the density of the gas, the length of the light path, the Rayleigh scattering function of the gas, and the absorbance coefficients of any electronic transitions availible to the gas molecules or atoms in the visible range.
First of all, gas molecules are not invisible. There are plenty of elements whose gaseous state is quite colored, but these (iodine, e.g.) are in such rare amounts in the atmosphere that the net effect is not discernable to the eye. Next, if you Google for "atmospheric transmission curves," you'll see all sorts of spectral absorption going on, again at rates which aren't normally detectable by your eye.
As it happens, the more prevalent species (nitrogen, oxygen, CO2, etc) do not absorb or reflect significantly over the visible spectrum. That's partly (although not entirely -- this becomes a biological rather than physical question) why our eyes see in the range they do.
EDIT: per @DavidRicherby's request adding: these gases do not absorb because they have no resonances or electron shell gaps to match -- or as everyone's said, because what absorption cross-section they have is small enough that the net effect is not distinguishable to our eyes
As has been said by many answers; all gases aren't colourless, for example chlorine gas is a pale yellow; which is a good thing as it's very dangerous.
So the gases in our atmosphere are colourless. But this is completely the wrong way round to look at it. If our eyes operated at frequencies that were blocked by gases in the atmosphere they wouldn't work very well. And this is an important point because the gases in our atmosphere aren't transparent at all frequencies. For example this is the absorption spectrum of water vapour:
If our eyes operated around 100 nm we would live in a very dark world, almost all the light would be absorbed by the atmosphere. The same if they operated at 10 micrometres. But our eyes evolved to use the light that was available to them; and that light was between 400-700 nm; right in the middle of that drop in the absorption (obviously you'd need to look at nitrogen’s and oxygen’s absorption spectra as well to get a full picture).
So the reason we can't see common gases; because evolution optimised our eyes to work that way. Had we evolved in an atmosphere mostly made of chlorine gas I would wager that we would still be asking "Why can't we see gases?" and someone would come up with the counter examples of how the (on their world) rare gases water vapour, oxygen and nitrogen were visible.
Some gases actually are visible (nitrogen dioxide for instance). The air is invisible, because its molecules don't absorb the visible light. These molecules simply don't have useful vibration modes available to absorb these wavelengths, or the electrons in their orbitals can't utilize the frequencies of visible light to move to higher orbital (the energy differences do not correspond to visible light).
In some other part of the electromagnetic spectrum the air could be visible.
One of the reasons why the eyes became sensitive in the "visible" spectrum is that air does not absorb there. Otherwise the eyes would be useless: you would not see anything but air. Our eyes can tell us what is happening around only if they use the part of spectrum where air does not absorb.
One factor to keep in mind is that for a low-density material with relatively weak interactions with light, the total mass of the column that light passes through will make a big difference in the perceived color. For instance, if you fill a white bathtub with water, you'll notice that a centimeter-scale column of water from the tap (or from your water glass) is transparent, while the decimeter-scale column in the bottom of the tub is distinctly blue.
You can see the same effect if you look at a green or brown mountain from a few tens of miles away: the greens and browns are washed out by the blue color of the many tons of intervening air.
Why are liquids invisible? And why are gases like silvery blobs? (...asks a creature who spent their entire life underwater.)
Gases are transparent, not invisible. Life at the bottom of an 'ocean of air' can give certain air-breathing organisms a distorted viewpoint.
If we spent our lives in vacuum, then we'd think that both air and water were transparent fluids. We'd notice that air does bend light far less than the water does. In a vacuum environment, a clear bag of air would behave less like a lens, if compared to a clear bag of water.
Actual classroom demonstration: get an aquarium full of water. Fill a water-balloon. Now hold the balloon submerged in the aquarium, and let it release the water. See anything? Nope. This obviously proves that water is invisible. :) And if we had a gas-filled environment, and then released the contents of a gas-filled balloon, we could prove to ourselves that gas is invisible. No? We are airfish, living at the bottom of the nitrogen ocean, and firmly convinced that gas is an invisible material.
Here's yet another perspective: suppose that you're about 1000KM tall. You bend down, cup your hands, and scoop up some of Earth's atmosphere. Lift it high into the vacuum. It looks like translucent light-blue smoke! The KMs-deep pool of air in your hands makes your palms a bit hard to see. Pour it out again, and as it falls it forms a brilliant sky-blue plume against the blackness of space. Obviously air is far from invisible.
Gas can be hugely visible. The sun is all made of gas and is totally intransparent. Inside the sun light particles (photon) travel only centimeters (in the very deep) to kilometers (nearer the surface) before being absorbed. Not really different than other "particles" of the local gas. So you can't see into the sun in light (you can using acoustic waves as subsurface diagnostc but that is another story).
What we call "the solar surface" is the layer far out where the gas gets tenuous enough to become transparent. There the photons escape as sunlight. The gas there is actually much less dense than the transparent air around us because it is made up of nearly pure hydrogen (making it quite opaque to visible light if sufficient hydrogen atoms grab an extra (second) electron, a process only understood in the 1940s).
A small fraction of the very small fraction that happens to strike the earth gets scattered in our atmosphere; those that happen to bounce towards your eye make up the blue sky that you see. Blue not because they change in energy (color), only because more photons get scattered in the blue than in the red - so the sun shows red at sunset because more blue went out of the direct way to your eye.
The question is good because intransparency of gases appears counter-intuitive to us. This is why "radiative transfer in stellar atmospheres" is an advanced topic in astrophysics courses. The light that comes out of stars is our main diagnostic to understand them, but interpreting this light needs good appreciation of the stellar gas' intransparency. Google this topic and read my lecture notes...
Visibility is subjective
Visibility is subjective, you need an observer.
You asked for the story. It starts with our earliest ancestors, who developed sensors that were sensitive to electromagnetic radiation.
What kind of sensors and what kind of radiation? Whatever made a difference.
In the beginning? Whatever radiation was available, whatever got through the atmosphere with sufficient energy to reach the surface of the earth.
As the atmosphere changed, so did the sensors adapt to the radiation that would get through.
Over time, those sensors evolved into eyes. As they did with many other species.
I just had to interject here!
In the expansion of your question you ask that
I am not sure what causes gas molecules to be invisible
Well, all "molecules" are invisible to our eyes, we just don't have the resolving power to see them, if you have an atomic force microscope you can see them like this
However you can see many gases in general like @DavePHD has clearly shown!
If you still intend to talk about the fact that you can see pretty much all solids or liquids and not all gases, then you must take a look at people banging themselves in mirrors or glasses as those too become invisible to us at various occasions.
While pretty much all solids and liquid are organised enough to at least reflect light, gases are too scattered to do that! The only property which allows gases to become visible is the absorption or emission of photons, if during absorption the complementary light is in visible range we can see the gas, and if emitted light is in visible range we can see it, otherwise we just can't not with our eyes!
In the last paragraph, do not think about fog or other such things that look like gases and say that those reflect! There are other phenomenons which play there and furthermore fog is not gas! Reflection only takes place from gases when it is impure and is more of a colloidal nature, as it is in smoke that the pollutant particles make it look black/grey/white!
There is a biological component to the answer. In effect, the environment selects the attributes that increase the chance of a species being successful in passing on its genes to future generations. Based on this, if a sense such as vision develops in a species, it will evolve in a way that maximizes the usefulness of that sense. For earth's atmosphere, various specie's eyes are "tuned" to the specific wavelengths of light that are not absorbed by the atmosphere, because those wavelengths give those species the most information about their environment, and hence, increase their chance of reproducing.