The Sun and all planets attract each other with their gravitational pull. As the Sun has by far the greatest mass, all planets
rotate around it. The Moon rotates around the Earth for the same reason – the Earth is over 30 times more massive than the Moon. We see the attraction of the Moon from the tides:
it tugs at the water in the oceans and creates high and low tides.