Answer: High Temperatures from the sun
Step-by-step explanation:
Due to the high temperatures radiating from the sun, only materials that had high melting points could survive around it as opposed to those with low melting points that became vaporized into gas. These materials with higher temperatures were then pulled by the gravity of the sun and kept colliding till they formed the inner planets closest to the sun being Mercury, Venus, Earth and Mars.
The other materials that were with low melting points which became gas spread to the outer part of the solar system and as they became ice, they came together and formed cores with gravities that pulled other gases till they formed the gas giants as we know them today.