Earth in its early stages was like a depiction of hell, scalding rock and choking fumes, due to accretion from cosmic debris. The surface was essentially a magma ocean, much too harsh of conditions for anything to survive. Some water and a very early atmosphere was present, and crustal rocks began to form. But the mantle was convecting and volcanism was intense. Large asteroids kept falling in, producing craters and an overall large-scale disturbance.
The Earth formed approximately 4.56 billion years ago out of the dust and gases surrounding the sun called the protoplanetary disk. A combination of solar radiation not allowing for the condensation of lighter materials inside the frost line, as well as solar wind forcing lower density hydrogen and helium into the outer solar system left behind only the heavier rocky materials to create the smaller terrestrial planets. The rocky dusts and gases which were left in the inner solar system coalesced together through processes of collision, condensation and accretion forming planetesimals of approximately 10-100km in size. Once they reached that size, the planetesimals had enough mass to begin attracting additional matter through gravitational forces and the largest grew quickly from planetesimals to protoplanets. As protoplanets slowly transformed into planets, heating caused by gravitational pressure, impacts from small and large solar bodies, and higher concentrations of radioactive elements melted the material the protoplanets were conglomerated from allowing the denser materials such as magnesium and iron to sink towards the center while the lighter silicate materials such as feldspar and quartz rose to the surface. This differentiation of materials created the Earth's core of iron and the mantle and crust of lighter materials.
While the Earth was still in this hot molten form there was a collision with the Earth knocking the planet’s tilt off of the axis to approximately 23.5 degrees away from the plane of the ecliptic or celestial equator.