Here's why:
* Sound travels as vibrations: Sound waves travel through a medium by causing particles within that medium to vibrate. These vibrations are passed from one particle to the next.
* Density affects vibration transmission: In denser materials, particles are closer together. This proximity allows vibrations to be transmitted more quickly and efficiently. Think of it like a tightly packed crowd: it's easier for a wave of motion to spread through the crowd than if everyone is spaced far apart.
* Liquids and solids are denser: Liquids and solids have much higher densities than gases like air. This means their particles are much closer together.
Other factors:
While density is the primary factor, the elasticity (ability to return to original shape after deformation) of the medium also plays a role. Solids are generally more elastic than liquids, which contributes to a faster sound speed in solids.
In summary: The higher density and elasticity of liquids and solids allow vibrations to travel through them much faster than through air, resulting in a greater speed of sound.