Earth formed around 4.6 billion years ago from a large cloud of dust and gas particles that collided under the force of gravity. As these particles slammed together, the early Earth experienced immense heat that melted the cosmic dust within its interior, forming a magma ocean deep underground. During Earth's early history when it was still young, intense volcanic activity and lava flows at the surface were caused by heat from the interior as well as constant bombardment from huge objects like the Moon or Mars. Over time, Earth cooled and conditions became stable enough for life to emerge as the geological eras progressed.