It is because pressure and density both contribute to sound velocity equally, and in an ideal gas the two affects cancel out, leaving only the effect of temperature. Sound usually travels more slowly with greater altitude, due to reduced temperature.