It simply reflects sunlight. So when the moon passes into the earth's shadow it goes dark. Interestingly, though, it doesn't go completely dark. A small amount of light passing through the earth's atmosphere is bent just enough to dimly light the moon with a pale reddish color. Lunar eclipses occur infrequently.
Some years have none, but there can be as many as three in one year.
A solar eclipse occurs when the moon passes between the earth and the sun. The sun is about 400 times larger than the moon, but it's also about 400 times farther away. So the son and moon appear the same size in our sky. Therefore, then the moon passes exactly between the erath and moon, the sun's disk is completely covered, allowing us to see the corona, the layer of hot gasses surrounding the sun. Solar eclipses occur more often than lunar eclipses.