The knowledge about earthquakes and the science of seismology has come a very long way in the last couple centuries. Back then, all quakes were deemed to be retribution by an angry God or gods. The idea that there might be a physical cause simply didn’t occur to most people.
One of the biggest breakthroughs came when the idea was put forth for Plate Tectonics and continental drift. Still, it took some time for the notion to be accepted.
The theory of continental drift sees the upper most solid layer of the earth, the crust, as being divided into many sections or plates, each moving independently of each other on the elastic and extremely hot mantle beneath it. While now accepted, in the past many people had a hard time believing that something as big as a continent could be moving.
Part of the difficulty was also that it showed that the Atlantic Ocean is getting broader, which meant logically that new crust was being created. That would mean, though, that the crust was getting destroyed in another location. We now know both to be true. Where the crust is getting destroyed is called a subduction zone, and is actually where one plate slides beneath another plate. This is occurring in the Pacific Ocean near the west coast of the US, though it also occurs in other locations.
This is the main mechanism for most major earthquakes. As plates move past each other, especially near subduction zones, the movement is rarely smooth. So if the plates catch each other, tension builds up until the rock breaks from the strain, creating an earthquake. Areas where there is a strain are called faults. The severity of the earthquake primarily has to do with how long the pressure has been building, the depth of the break, and the amount of rock that is displaced.
As explained, this is the mechanism for most major quakes, but not for all of them. Earthquakes can happen prior to, during, and just after volcanic eruptions as magma moves from one location to another, breaking and melting rock as it does. There is still a connection to the continental drift, however, since many volcanoes occur near subduction zones and form as one plate begins to melt as it slides beneath the other.
Quakes can also be created by the activities of man, such as explosions, mining operations, and even the creation of reservoirs. In the last, the weight of the water forces some of the water down into tiny cracks in the bedrock, where it acts as a lubricant, releasing tension in small faults, many of which were not previously detected.
The actual shaking is in the form of three main kinds of seismic waves that move at different speeds from the origin of the quake. One kind is mostly responsible for the up and down motion, while another is responsible primarily for the side-to-side motion, and the third is much more of a rolling or shearing wave like you might see on the ocean. It is the combination of the waves that cause wide spread damage.
Because the entire process is a dynamic one, constantly changing, and because the earthquake waves function a little differently depending on what sort of material they pass through, prediction is exceedingly difficult. Precursors to a quake in one area might be totally absent in another. Some of the biggest efforts are currently on identifying which areas have the greatest about of stress, but even that is a guessing game; one that uses very high tech devices.
All we can be reasonably certain of is that earthquakes will continue to happen for a very long time.