Sound wave passes through a medium by transmission of compressions, similar to the transmission of vibrations through a spring. The stiffer the spring is, the faster is the transmission speed. In fact, the speed of sound depends on two factors, the stiffness (i.e. the elasticity) of the medium where the sound wave travels, and the density (i.e. how close molecules are packed) of the medium. Since variation in stiffness between the three states is much larger than variation in density, the speed of sound is thus determined mainly by the stiffness of the medium. The stiffer the medium is, the higher is the speed of sound passing through it.
Stiffness of a substance is measured in physics by the term "bulk modulud". Bulk modulus for solids is around hundreds of GPa (e.g. the bulk modulus of steel is about 200 GPa). Solids have the highest stiffness when compared with liquid and gases. This is the reason why sound wave travels faster in solids than in liquids and gases.
Liquids have lower values of bulk modulus, i.e. less stiff. For example, water has a bulk modulud of about 2.2 GPa. Therefore, sound waves travel in water is slower than when travel in steel.
Gases have the lowest bulk modulus. For example, air has a bulk modulus around 0.00014 GPa. The speed of sound in gases is thus the lowest.
The following web-page contains good information describing the speed of sound, you may wish to have a look on it, especially the paragraphs under the section "Basic Concept":
http://en.wikipedia.org/wiki/Speed_of_sound