The extreme temperatures on Moon are due to the lack of atmosphere. Moon has an average daytime temperature of about 100 degrees C and a night time temperature, as low as -173 degrees C. The lack of atmosphere means that there are no gases and clouds to hold the heat and spread it to the colder regions. There are also no oceans to hold the heat and loss the heat by evaporation, thus, maintaining the surface temperature. Due to all these factors, Moon surface warms up quickly when it faces the Sun and loses all this heat when it is shaded from the Sun.
To compare, Earth is also about the same distance from Sun. Yet, our temperatures are more moderate, since the atmosphere traps some heat and distributes it. Our oceans also help in storing the heat and losing heat by evaporation of water, thus maintaining a more hospitable temperature range, as compared to the Moon.
Hope this helps.