During the day (daylight) the sky has a blue appearance because the Sun’s light (white light) is made up of rainbow of colors (red, orange, yellow, green, blue, indigo and violet) of different wavelength. This means, all these different colors of light combine to give you what is called white light. When sunlight enters the Earth’s atmosphere, it collides with air particles that causes the scattering of sunlight around the sky. The light with the shorter wavelength is scattered more by this collision than light with longer wavelengths. In this case, violet light is scattered the most, but human eyes do not see this color very well. However, since the human eyes are more sensitive to blue light (the next most scattered visible color), you will see the sky as blue. This therefore means that the blueness of the sky is from the blue light that is scattered from the sunlight in the atmosphere which, then enters our eyes from all regions of the sky.
The black sky at night that shows you the moon, planets and stars is due to the absence of the Sun’s light. The overwhelming effect of the Sun’s light reacting with the atmosphere blacks out (conceal) the blackness of the sky (outer space). This means therefore that because there are no scattered light to reach the eyes of an observer during the night (to conceal the viewing of outer space) we get a clear (transparent) view of space, which is black. So, the sky is black during the night because it is revealing outer space.
It is also important to note that, the moon does not give its own light but reflects the light from the sun. This reflected light from the moon is not strong enough to have the same effect (of blotting out the view of outer space) as the Sun.