Though at a glance, the surface of earth seems completely stationary and dead, the fact is that a lot of things keep occurring inside the surface of our planet at all times. This movement that continuously happens inside the surface of the earth, results in everything from volcanic eruptions to earthquakes. The results of both could be extremely devastating at times and the world has seen the aftermaths caused by such natural disasters.
The answer to the question of why exactly do earthquakes happen can be attributed to the plate tectonics. The movement of plates, which create everything from continents to mountains, are always in motion and this motion causes immense stress on the continents and oceans. While at some places, this stress is usually small, elsewhere, especially where the plate meet each other, the stress is extremely high. In such places, plates move against each other and cause compression stress, pull each other to cause extensional stress and slide part each other to create tensional stress.
Since this stress is building at all times, faults or breakage usually occur. While most of the faults are locked and hence cannot release the strain, away from the fault, the stress produces a small but a slow movement of the rock masses as a whole. Eventually, the strain is too much for the surface of handle and the fault releases all the strain at once and this release of strain results in earthquakes. The intensity of the earthquake depends directly on the size of the fault, the bigger the fault, the bigger the strain and hence the bigger is the earthquake.