Earthquakes occur when there is a sudden release of energy in the Earth's crust, typically resulting from the movement of tectonic plates. This movement causes stress to build up in the rocks along fault lines until it is released in the form of seismic waves, which we feel as an earthquake.