Most of the heat at Earth’s surface comes from sunlight. During the day in a desert such as the Sahara, a lot of sunlight heats the ground, which then heats the air. At night, that heat escapes into space, which makes the temperature in the desert drop very low.
In areas that are not deserts, clouds prevent some sunlight from reaching the ground. That’s why the days are not so hot. Clouds also stop much of the heat from radiating into space, which explains why the nights are not so cold.