Two main factors :
First, the distance from the earth to the sun allows enough heat (energy), not too much, to be absorbed on earth's surface.
Second, earth's atmosphere allows it to keep most of the heat it absorbed during the day for the night. Otherwise, temperatures would drop down below a life sustaining point.