The earth has an atmosphere that can reflect absorb and emit radiation:
During the day, more energy is being absorbed by the earth and atmosphere than is being emitted:
whereas at night time less energy is absorbed than emitted:
some part of the earth is always in the sun: