ONE reason the moon has craters because it gets hit by objects, small pieces of rocks that come from outer space. These are pieces of asteroids, comets that are flying around in the solar system. When they hit the surface, there’s an impact.
The moon has no atmosphere, and so even a tiny rock will create a crater. Typically when you see an impact crater, the size of the crater is much larger than the size of the the rock that created it.