Why are the planets closest to the sun composed of mostly rock while those further away are composed mostly of gas and ice?

Q&A Education