Earthquakes are mainly known to occur at plate boundaries where plates converge, diverge or slide past each other. Earthquake activity sometimes accompany volcanic eruptions but these too are concentrated around some plate boundaries (convergent, divergent).
Smaller earthquakes are known to occur in intra-plate regions, away from margins. These occur simply because of stresses being built up in rocks. The crust is solid and rigid and it floats on the mantle which is a curved surface like the crust.