The moon plays a larger role than the sun in causing tides in the oceans because it is much closer to Earth and has a stronger gravitational pull on our planet. The gravitational force between two objects is directly proportional to their masses and inversely proportional to the square of the distance between them.
Although the sun is much larger than the moon, its gravitational pull on Earth is much weaker because it is much farther away. The moon, on the other hand, is much smaller than the sun, but it is much closer to Earth and exerts a stronger gravitational force on our planet. This gravitational force causes the water in the oceans to bulge towards the moon, causing high tides.
In addition to the gravitational force, the shape of the ocean basins, the rotation of the Earth, and the positions of the sun and moon also play a role in causing tides. However, the moon's gravitational force is the primary factor that causes tides in the oceans.