The reason the sky is blue on Earth is because of the Earth's atmosphere. The molecules and gas in the atmosphere interact with solar light via Rayleigh scattering, which allows for blue light to be scattered more efficiently than lower frequencies. This results in an abundance of blue light, which makes the sky look blue. Actually it should be said that violet is the best scattered frequency in the visible spectrum, but we see blue because of the receptors in the human eye. See here.
There is no atmosphere on the Moon, so no scattered light and no colour blue.
But why is the sky black?
1) Our eyes are only sensitive to a narrow region of the electromagnetic spectrum. If we could see X-rays and radio waves, it would certainly be much brighter.
2) Many stars in the universe are so far away that their light has not had the time to reach us yet.
3) Stars recede due to the expansion of the universe. As they do so, their emitted light goes down in frequency (gravitational redshift): at some point, their emitted light will not fall within the visible spectrum and we won't be able to see it anymore.