San Francisco is located on the San Andreas Fault, which is the boundary of the Pacific and North American plates. The friction between these two plates as they slide past one another is the cause of the earthquakes in the San Francisco Bay area.
The plates are moving in opposite directions past each other at a speed of only a couple inches per year. Though seemingly insignificant, the plates are pressed hard up against each other and will lock into position for years at a time despite the underlying movement. When the pressure reaches a critical point, the plates jolt out of the locked position, resulting in tremors and earthquakes. This type of fault is called a transform fault.