Tides are a regular and ubiquitous phenomenon for those living near the sea. The periodic rising and falling of the sea level can be as small as 18 inches or so at mid-ocean locations such as Hawaii, or as big as 40 feet in narrow bays such as the Bay of Fundy in Canada. However, regardless of the amplitude of the tides, they all have the same period; at virtually all seaside locations, there are two high tides and two low tides every 25 hours.
The cause of the tidal flows of water can be attributed mainly to the gravitational influence of the Moon. Just as the Moon feels the gravitational pull from the Earth (that's why it orbits the Earth), so too the Earth feels a pull from the Moon. At the surface of the Earth, the pull from the Earth is much stronger than the pull from the Moon, because 1) we're a lot closer to the Earth (i.e. we're standing on it), and 2) the Earth is a lot more massive than the Moon. So just because I tell you that we feel a pull from the Moon doesn't mean we're going to start floating off the surface of the Earth toward the Moon! The Earth's hold on us is way stronger.
However, the Moon's gravitational pull is strong enough to play some tricks here on the surface of the Earth. These tricks come about not because of the strength of the Moon's pull, but because of how it changes depending where on Earth you are. Recall that the gravitational pull is stronger when you're close to a massive object than when you're further away. Thus the side of the Earth facing the Moon feels a stronger pull than the side facing away from the Moon, and at a point in the center of the Earth, the pull from the Moon in intermediate in strength between those two extremes.
To see how this affects the flow of water in the Earth's oceans, let's examine a simplified model of the Earth. Let's assume that the Earth is completely covered with water to the same depth everywhere. Then, in the absence of any tidal forces, a slice through the Earth at its equator would look like the drawing below:
In this case, the water doesn't flow anywhere, because it only feels the gravitational pull from the Earth itself, and that pull is the same in strength and directed toward the center of the Earth everywhere.
So what happens, when we include the effect's of the Moon's weaker, but varying gravity?
On the side of the Earth nearest to the moon, the pull from the Moon (indicated by black arrows) is the strongest. It's clearly stronger than the pull from the Moon at locations on the Earth further away from the Moon. That's why the water flows in the direction of the blue arrows toward the closest-to-the-Moon (a.k.a sub-lunar) point. It's literally being pulled by the Moon toward this point. The water isn't fighting against the Earth's gravitational pull since it's flowing along the Earth's surface. The water piles up at the sub-lunar point and the sea level is a little higher there.
OK, so maybe that explains why the water should be a little deeper at the sub-lunar point, but why should there also be a pile-up at the other side of the Earth? That's a little harder to explain, even though it's exactly the same effect that creates a build-up at the sub-lunar point. The key is to realize that it's the difference in the gravitational pulls that matters, not the magnitude at any one place. Because the gravitational pull from the Moon is less at the farthest-from-the-Moon (super-lunar) point than it is at other locations on the surface of the Earth, the water at this point is literally left behind. The entire Earth is pulled by the Moon, but the stuff farthest from the Moon gets pulled the least. Thus, water piles up here as well, and there are two bulges on opposite sides of the Earth.
This double-bulge behavior occurs not only in the water on the surface of the Earth, but also (to a much smaller degree) to the Earth's crust itself. The Earth's crust bulges by about a foot in the same way due to the Moon's influence. The squashing of objects by an external gravitational pull happens not only to the Earth due to the Moon, but also, and much more spectacularly, to many of the moons which orbit the gas giant planets. Here these same tidal effects (this time due to the Jupiter's or Saturn's gravity) stretch and squash moons like Io and keep their interiors hot, and probably molten.
Tidal effects can be even more complicated when we add in the influence of other massive bodies. Though the Moon is primarily responsible for the ocean tides, the Sun plays a substantial secondary role. It may surprise you to hear that the Sun plays second fiddle to the Moon here. After all, the Sun is much more massive than the Moon, and its gravitational pull is clearly stronger (the Earth orbits the Sun, not the Moon). However, tidal effects aren't about the strength of the gravitational pull from an object; they occur because of the differences between the pulls at two locations. Because the Sun is much further away from the Earth than the Moon is, the difference between the Sun's gravitational pull on one side of the Earth and on the other is pretty small, even though the magnitude of the pull at both locations is much bigger than the pull from the Moon.
Still the Sun exerts a tidal effect which is about half of the Moon's, so it's significant. However, the Sun and the Moon aren't always in the same part of the sky, so these two tidal influences don't always add together simply. When they are located in the same part of the sky, as in the figure below, their influences add, and we get extra high tides.
These extra high tides are called spring tides, though they have absolutely nothing to due with the season Spring. You can see from this diagram that spring tides occur when the Sun, Moon, and Earth are lined up. That occurs during two phases of the Moon -- New and Full. Which phase is depicted in the above? Can you draw a diagram for the other phase which should have spring tides?
Sometimes the Sun and Moon work against each other, as in the digram below.
Here the Sun and Moon are pulling in different directions. The tidal effect due to the Moon is greater, so the Moon wins, and the high tide is located at the sub- and super-lunar points; however, because of the Sun's mitigating influence, these tides are smaller in amplitude. That is, the high tides aren't so high, and the low tides aren't so low. These wimpy tides are called neap tides and they occur at First Quarter and Last Quarter phases of the Moon (hopefully, you can see why).
OK the last bit to think about is how all of the timing works out. So far, we've showed that there are two high tides and two low tides at any time on our idealized watery model of the Earth. Now we just need to remember that the Earth rotates on it's axis once every 24 hours. That means that every point on the Earth's surface will rotate through each of these zones of high and low tides over the course of 24 hours. In looking at the figure below, think of viewing the Earth from above the North Pole. The high tides stay aligned with the position of the Moon, while the Earth rotates. This creates two "waves" of high tides, which sweep across the globe.
The timing of the tides is complicated just a little bit more by the fact that after 24 hours, the Moon has actually moved a bit in its orbit around the Earth. As a result, in order to get back to the high tide bulge, we have to rotate a little bit further than just one rotation. (see figure below) How much further? About our hour's worth of rotation. Therefore, there are typically two high tides every 25 hours, rather than every 24 hours. This is why the times of high tides are about an hour later each day. You may have noticed that the Moon rises about an hour later each night, too. Same reason.
The final details of the story of ocean tides have to do with the geography of the the ocean's shoreline. In some places, perhaps because of the location of islands, water can't flow completely freely, and so the tides are delayed by a bit. This happens, for example, in Long Island Sound between Long Island and the Connecticut coast.
Time of high tides on the northern side of Long Island are considerably different from the times of high tides on the southern side, which faces open ocean. Local geography also plays a big role in how high the tides are. The Bay of Fundy in Canada is a long, relatively narrow stretch of water, and the timing of the tides creates a resonance in this body of water, much like the huge waves my kids can make in the bathtub by waving their hands at just the right frequency. This resonant sloshing in the Bay of Fundy creates huge tides, where the level of the ocean changes by 40 feet every six hours. This change in sea level is so big and occurs in so short a time that rivers flowing into the bay actually turn around and start flowing backward as the tide comes in. The tide rushes in so fast that it creates a tidal bore -- an incoming wave as much as ten feet high! The effect is so wild that whitewater rafting trips are run upriver in this turbulent water. Take a look at this Web site to see some images of the tidal bore.