Our galaxy, the Milky Way, was formed by the merger of several other galaxies.
Astronomical data and hydrodynamic models of star formation support the idea that stars, including the sun, formed by the gravitational collapse of a molecular cloud core made of material manufactured and reprocessed in many previous generations of stars. The forming star is surrounded by a rotating disk of gas and dust because the typical molecular cloud rotates at the time of collapse. When observed through a telescope, the majority of the disc surrounding the young stars is made up of 99 percent gas and 1 percent dust.
According to Core Accretion Model, The development of the Giant planet began with the condensation and coalescence of rocky and ice material to produce masses several times the size of Earth. These solid bodies then attracted and accumulated gases from the circumstellar disk.
Disk Instability Model suggests, that the development of gas giant planets does not require the presence of a rock or an ice ball; they can originate directly from the gas and dust in the disk, which can collapse under its own gravity like a miniature sun.
This is how giant gas planets like Jupiter and Saturn were formed. Solar wind clears out much of the gas disk, ending growth by gas accretion.
As the Solar Nebula began to cool the remaining dust grains started to bind together. The further development of a Terrestrial planet is thought to have occurred in phases, beginning with the production of a small planetesimal about 10 km in diameter. Many of the early plants were destroyed as they collided.
Planetesimals that were not destroyed expanded quickly to the size of a moon (>1000km diameter). This rapid accretion quickly began to reduce material in the vicinity surrounding the planetesimals from which it was growing.
These planetesimals created a few planetary embryos that were around the size of Mars (>5000 km diameter). Only a few planetary embryos were growing and they all grew to be around the same size. Accumulation slowed as planetary materials were accreted from the surrounding.
Jupiter migrated inward, preventing planet formation in the asteroid belt and limiting Mars' material supply. After that, it entered a resonance with Saturn and moved to its current orbit.
Iron, the most abundant element capable of forming a dense molten metal phase, gathered in planetary core. Siderophile ("iron-loving") elements descend into the core because they dissolve easily in iron, either as solid solutions or in molten form.
Lithophile elements ("rock-loving") remained on or near the Earth's surface because they readily react with oxygen to create compounds that do not sink into the Earth's core.
At temperatures and pressures found on the surface, atmophile elements (also known as "volatile elements") remain predominantly on or above the surface because they occur as liquids and/or gases.
The terrestrial planets most likely had magma oceans on their surfaces at the ending of planetary accretion. These formed crust when they cooled. Because of their strong attraction for oxygen, lithophile elements formed very strong associations with silica, resulting in relatively low-density minerals that float to the Earth's crust. This crust was most likely destroyed by major impacts and reformed numerous times until the Heavy Bombardment Era came to an end. None of the Earth's primordial crust has survived to the present day.
Terrestrial planets had largely formed by continual accretion of rocky protoplanets. The Moon formed as a result of a collision between a proto-Earth and a Mars-sized planet, throwing melted pieces of the planet's crust into space. Gravity held the expelled particles together, resulting in the formation of a moon.
The atmosphere couldn't form on the early Earth because it was too hot. Any gases that were superheated and released into space. However, clouds began to form in the atmosphere once the Earth cooled sufficiently, sometime during the first 700 million years of its life, and the Earth entered a new stage of evolution. It started pouring outside. It rained and rained and rained. Torrential downpours lasting millions of years formed the Earth's oceans, allowing new chemicals to be formed in a liquid environment. Subsequently giving a platform for origin of Life.