The speed of sound depends on the density of the medium in which it is travelling and increases when the density increases. For example, in solids sound travels faster than in liquid and even faster than in gas, and the density is highest in solids, lower in liquids and lowest in gas.
So iron has a density of about 7,800 kg/m$^3$$7\,800\ \mathrm{kg/m^3}$, while mercury has 13,600 kg/m$^3$$13\,600\ \mathrm{kg/m^3}$, but the speed of sound is 1,450 m/s$1\,450\ \mathrm{kg/m^3}$ in mercury and 5,130 m/s$5\,130\ \mathrm{kg/m^3}$ in iron, so mercury has a higher density, but sound travels slower in it. Why is this?