Answer: The short answer is that earthquakes are caused by faulting, a sudden lateral or vertical movement of rock along a rupture (break) surface. Here's the longer answer: The surface of the Earth is in continuous slow motion.
They're usually caused when rock underground suddenly breaks along a fault. This sudden release of energy causes the seismic waves that make the ground shake.