Rocks are classified into three main types based on how they are formed: igneous, sedimentary, and metamorphic. Igneous rocks are formed from the cooling and solidification of magma or lava. Sedimentary rocks are created from the accumulation and cementation of sediments, while metamorphic rocks are formed from the alteration of existing rocks due to heat and pressure. Each type of rock has unique characteristics and properties that can provide valuable insights into Earth's geological history.