The Moon shines by reflecting light from the Sun. We see this reflected light on Earth, and the various phases are produced by the changing orientation of the illuminated hemisphere of the Moon which always faces the Sun, and the location of the Earth relative to the Sun-Moon line.