Answer:
The closer a planet is to the Sun, the warmer it would be. Gases move faster the hotter they are and if they are fast enough (escape velocity), they can escape the gravitational field of their planet and spread in the space. Further planets are gaseous because their gases don't have the energy to escape their gravitational pull