At the particle level, a rigid material is characterized by atoms and/or molecules with strong forces of attraction for each other. These forces can be thought of as springs that control how quickly the particles return to their original positions. Particles that return to their resting position quickly are ready to move again more quickly, and thus they can vibrate at higher speeds. Therefore, sound can travel faster through mediums with higher elastic properties (like steel) than it can through solids like rubber, which have lower elastic properties.
The phase of matter has a large impact upon the elastic properties of a medium. In general, the bond strength between particles is strongest in solid materials and is weakest in the gaseous state. As a result, sound waves travel faster in solids than in liquids, and faster in liquids than in gasses.
Density describes the mass of a substance per volume. A substance that is more dense per volume has more mass per volume. Usually, larger molecules have more mass. If a material is more dense because its molecules are larger, it will transmit sound slower. Sound waves are made up of kinetic energy. It takes more energy to make large molecules vibrate than it does to make smaller molecules vibrate. Thus, sound will travel at a slower rate in the more dense object if they have the same elastic properties.