Why does the moon go around the earth rather than the sun?
The Moon is close enough to Earth, so that Earth's gravity keeps the Sun from pulling the Moon away.
The Moon is on average only about 380,000 km away. The nearest any other planet comes to Earth is about 100 times that far (Venus). This makes a big difference in the significant amount of gravity Earth can exert on the Moon, versus the impotent gravity of Earth on Venus or Mars.
How close is close enough to keep the Moon close by or any moon close to its parent body? See here: