How did the outer planets form?
From a cloud of dust and gas.
All planets including the outer larger planets were formed at the same time somewhere around 4.5 Billion years ago. It all started with a cloud of dust and gas that had a small rotation, when the cloud collapsed mainly because of some gravity event of a nearby dying star the objects in it and the disk itself began to move faster and the Sun came into existence. In the beginning our Sun was much more brighter and Luminous than today. The young sun drove away most of the gas from the inner solar system, leaving behind the rocky cores also known as the terrestrial planets.
In the outer solar system the radiation of the sun was not sufficient enough to drive gas away from the outer planets, as the gas was already present in that part, the rocky cores were able over time to accrete mantles of Hydrogen and Helium.