The Moon orbits the Earth —not the Sun— because the Moon lies well within Earth’s Hill sphere. Hill sphere is the region around Earth where Earth —instead of the Sun— dominates the attraction of satellites.
Flat-Earthers noticed the Sun exerts a stronger pull to the Moon than Earth does to the Moon. They incorrectly concluded that according to science, the Moon should orbit the Sun, then proceeded to use it to discredit science. In reality, they did not account for the centrifugal acceleration resulting from the motion around the Sun, which is one of the factors that determines Earth’s Hill sphere.
The Moon is affected by the Sun’s and Earth’s gravity and the centrifugal acceleration from the motion of the Earth-Moon system around the Sun.
A satellite tends to orbit Earth —not the Sun— if Earth’s gravity + the centrifugal acceleration is greater than the Sun’s gravity. The satellite’s distance from Earth determines that. The farther it is from the Earth, the stronger the attraction the Sun exerts to the satellite. The region where Earth’s gravity + the centrifugal acceleration is greater than the Sun’s gravity is called the Hill sphere of Earth.
Earth’s Hill sphere is ~1500000 km. The Moon is 384400 km away, well within Earth’s Hill sphere. Therefore, the Moon orbits Earth, not the Sun.
Calculations
The Moon’s case:
- Sun’s distance = 1 AU
- Moon’s distance = 406700 km (the farthest point from Earth)
- Sun’s gravitational acceleration = G * solar mass / (AU-406700 km)^2 = 0.00596433161 m / s²
- Earth’s gravitational acceleration = (G * earth mass) / ((406700 km)^2) = 0.00240977603 m / s²
- Centrifugal acceleration = ((G * solar mass) / (AU^3)) * (AU – (406700 km)) = 0.00591581945 m / s²
- Total acceleration away from the Sun = 0.00240977603 m / s² + 0.00591581945 m / s² = 0.00832559548 m / s²
Because Sun’s gravitational acceleration is less than the total acceleration away from the Sun, then it is possible for the Moon to orbit Earth.
The case of an object at the edge of Earth’s Hill sphere:
- Sun’s distance = 1 AU
- Object’s distance = 1500000 km
- Sun’s gravitational acceleration = G * solar mass / (AU-1500000 km)^2 = 0.00605271739m / s²
- Earth’s gravitational acceleration = (G * earth mass) / ((1500000 km)^2) = 0.00017715055 m / s²
- Centrifugal acceleration = ((G * solar mass) / (AU^3)) * (AU – (1500000 km)) = 0.00587246725 m / s²
- Total acceleration away from the Sun = 0.00017715055 m / s² + 0.00587246725 m / s² = 0.0060496178 m / s²
The sun’s gravitational acceleration is about the same as the total acceleration away from the Sun. It will not be possible for an object here to have a stable orbit around Earth, nor around the Sun. But it is possible to have a stable orbit around this point at the edge of Earth’s Hill sphere, which is called the Lagrangian point L1.