The ocean’s tides are affected by gravitational pull of the moon on the Earth. There is also a mutual pull of the Earth on the moon, which keeps the moon in orbit around the Earth.
Imagine floating out in space, looking at the Earth, and watching the moon orbiting the Earth. The Earth is turning on its axis every 24 hours. As the Earth turns, the moon’s gravity pulls on the ocean waters, causing a bulge on the moving area of the Earth, closest to the moon. Another bulge forms on the opposite side of the Earth, furthest from the moon. This is because the gravitational pull on Earth pulls the Earth away from the water. Also, the attraction of water molecules to each other allow for the ocean water to “pile up” in that area. The Earth is also pulled toward the moon in that area. The places, on the Earth, where the water bulges, are where there are high tides. The bulge follows the moon, as the moon orbits around the Earth, and the friction of the water causes a slight lag in the bulge. This results in two high tides about every 12 hours apart and two low tides in between each high tide. The lag time in the bulge as it follows the moon’s orbit, accounts for a daily time change in the tides.
If the height of the tide is measured at the same point every hours, for a 24 hour period and graphed, the height of the tide vs. the moon’s position and time will reveal that the tide is highest when the moon is in transit (directly over head or on the opposite side of the Earth) and low during moon rise and moon set.
The sun, in combination with the moon, also affects the tides, resulting in spring and neap tides. That celestial dance will have to be explained in another article.