Denser objects and substances experience a greater gravitational force acting upon their mass. This is why materials of different densities form layers. It is less dense than the Earth's crust, which is a solid. This is why the Earth's surface and atmosphere form distinct layers.
Earthquakes occur when stress builds up in the Earth's crust and causes it to break in a line known as a fault. A fault is a crack in the Earth's crust caused by stress in the surrounding rocks.