Turboprops are more efficient, because they accelerate more air by less to create the thrust, and therefore the air carries away less energy , since kinetic energy is proportional to square of velocity. This is true at all altitudes.
Neither engine benefits from altitude. They do benefit somewhat from the colder temperatures up high as heat engine efficiency is proportional to the ratio of high and low absolute temperature. But the main benefit from flying high is that drag is proportional to density, so in the less dense air up high the aircraft flies faster with the same thrust. This is true for both engine types.
The key difference is that turboprops are limited by true airspeed as when the propeller tips get close enough to speed of sound, shockwaves start to form that create massive drag (and a lot of noise) and the efficiency declines fast. In contrast the inlet of a turbofan modifies the pressure field around it so that the air always hits the fan the same speed independent of the speed of the aircraft, converting the extra velocity to pressure instead. Therefore turbofans maintain their efficiency to higher true airspeeds.
Since the low density at high altitudes also increases true stall speed, the true airspeed restriction of turboprops creates an altitude restriction too.
So for short routes where there is not enough distance to climb up as high, the higher efficiency of turboprops is better and turboprops are used. But for longer routes where you can climb up above about 30,000 ft and fly most of the route there, the increase in efficiency due to lower density and resulting higher true airspeed offsets the lower efficiency of the turbofan engines and they become better.
Plus flying faster reduces other costs. For short routes the aircraft spends larger fraction of time on the ground loading and unloading and refuelling, so flying faster has less effect and you want to minimise the fuel burn. But for longer routes flying faster means the aircraft can make more trips in a given time and the crews can make more trips and therefore the fixed costs spread over more passenger miles, which makes it worth flying faster even if it means using a bit more fuel. That again requires using turbofan engines.