Why is earth made of rock?
Because rock by its very nature has a great mass than gas.
The four inner planets of our solar system are all made of rock. When our solar system was just beginning to take shape, the gravity of the sun had a much greater effect upon the rocks orbiting it than upon the gas orbiting it.
The next four planets are known as the gas giants because that is what they are mainly made of. But there does exist a caveat to this. We know some of the moons of Jupiter and Saturn are made of rock. That situation probably exists because the rocks that were furthest away from the sun became trapped by Jupiter's and Saturn's gravity and swung into orbit around them.