The planets in our Solar System can be generally divided into two different groups, the terrestrial planets and the gas giants. The terrestrial planets are closer to the Sun and consist of Mercury, Venus, Earth, and Mars. The gas giants are further from the Sun and consist of Jupiter, Saturn, Uranus, and Neptune. The frost line lies between the two groups. The frost line is the point in the Solar System beyond which hydrogen containing gas compounds like ammonia (NH3) and methane (CH4) can freeze and condense into ices. Between the Sun and the frost line, the temperature is too warm for these ices to form. So for the gas giants, their cores grew large from the formation of these ices, thus giving them a much greater mass and gravitational pull and allowing gaseous hydrogen and helium to accumulate near the cores to expand their sizes in comparison to the terrestrial planets.
"After the solar nebula collapsed to form our Sun, a disk of material formed around the new star. The temperature across this protoplanetary disk was not uniform. Since different materials condense at different temperatures, our solar system formed different types of planets. The dividing line for the different planets in our solar system is called the frost line" (Laboratory for Atmospheric and Space Physics, University of Colorado Boulder).
Thus, hydrogen compounds outside the "frost line" condensed into ice crystals instead of gases, like the inner planets. There was still some rocks and metals, but they were outnumbered by hydrogen compounds. As the hydrogen compounds began to come together and become more massive, they planets began to have a stronger gravitational pull. Eventually they began pulling in helium and more hydrogen as they grew in size.