The oldest material found in the Solar System is dated to 4.5672±0.0006 billion years ago (Gya). By 4.54±0.04 Gya the primordial Earth had formed. The formation and evolution of the Solar System bodies occurred along with those of the Sun. In theory, a solar nebula partitions a volume out of a molecular cloud by gravitational collapse, which begins to spin and flatten into a circumstellar disk, and then the planets grow out of that disk along with the Sun. A nebula contains gas, ice grains, and dust (including primordial nuclides). According to nebular theory, planetesimals formed by accretion, with the primordial Earth taking 10–20 Ma to form.
An subject of on-going research is the formation of the Moon, some 4.53 billion years ago. A working hypothesis is that it formed by accretion from material loosed from Earth after a Mars-sized object, named Theia, impacted Earth. In this scenario, the mass of Theia was approximately 10% of that of Earth, it impacted Earth with a glancing blow, and some of its mass merged with Earth. Between approximately 4.1 and 3.8 Gya, numerous asteroid impacts during the Late Heavy Bombardment caused significant changes to the greater surface environment of the Moon, and by inference, to that of Earth.
Earth's atmosphere and oceans were formed by volcanic activity and outgassing that included water vapor. The origin of the world's oceans was condensation augmented by water and ice delivered by asteroids, protoplanets, and comets. In this model, atmospheric "greenhouse gases" kept the oceans from freezing when the newly forming Sun had only 70% of its current luminosity. By 3.5 Gya, Earth's magnetic field was established, which helped prevent the atmosphere from being stripped away by the solar wind.
A crust formed when the molten outer layer of Earth cooled to form a solid as the accumulated water vapor began to act in the atmosphere. The two models that explain land mass propose either a steady growth to the present-day forms or, more likely, a rapid growth early in Earth history followed by a long-term steady continental area. Continents formed by plate tectonics, a process ultimately driven by the continuous loss of heat from Earth's interior. On time scales lasting hundreds of millions of years, the supercontinents have assembled and broken apart. Roughly 750 mya (million years ago), one of the earliest known supercontinents, Rodinia, began to break apart. The continents later recombined to form Pannotia, 600–540 mya, then finally Pangaea, which also broke apart 180 mya.
The present pattern of ice ages began about 40 mya and then intensified during the Pleistocene about 3 mya. High-latitude regions have since undergone repeated cycles of glaciation and thaw, repeating about every 40 000–100000 years. The last continental glaciation ended 10,000 years ago.
Explanation from: https://en.wikipedia.org/wiki/Earth