Water is the key factor here. Water has a high specific heat so it is able to retain, absorb and release a lot of energy. The absorbed heat is later radiated into the atmosphere. So, the layer of air close to the surface gets heated. This heat gets transferred vertically to the adjacent upper layers of air. Therefore, the temperature near the sea level is higher and it decreases at the mountainous region. High-altitude locations are usually much colder than areas closer to sea level. This is due to the low air pressure. Air expands as it rises and the fewer gas molecules including nitrogen, oxygen, and carbon dioxide has fewer chances to bump into each other. The human body struggles in high altitudes.