Tides are produced by a difference between the gravitational force acting on different parts of an object.
Tidal forces vary as the inverse cube of the distances between the masses.
The ocean waters flow into a bulge on the side of the earth facing the moon. On the other side of the Earth, there is a gravitational difference between the distance to the moon, and the Earth's center. The tides rise and fall twice a day, due to the moon. The Sun, also produces tides on the Earth. It is 27 million times more massive than the moon, but it is at the same time 400 times further away.