Why are near infrared telescopes located on mountaintops and ultraviolet telescopes in Earth orbit?

The primary infrared blocker, water vapor, is mostly in the lower atmosphere and the primary ultraviolet blocker, ozone, is located high in the atmosphere, far above mountaintops.