When the solar system was born why did Sun not consume all the planets by its immense gravity, as the planets were all gases, so it would have been very easy?
The answer is basically, angular momentum.
The collapsing proto-solar nebula has some angular momentum. Whilst dissipative processes can allow the nebula to collapse along the axis of rotation, there is still the problem of how to shed angular momentum in order to allow gas/dust to orbit closer to the rotation axis. This is just a basic application of Newtonian mechanics. Objects in orbits further out have more angular momentum. To move them inwards requires that they lose angular momentum.
This process is possible, there are various poorly understood mechanisms that can apply torques and move angular momentum outwards in the proto-solar accretion disk (e.g. the magneto-rotational instability, which increases the disk viscosity).
However, it seems (both from empirical measurements of circumstellar material in clusters of known age, and the presence of planets around most stars) that the timescales for the accretion of the disk due to its viscosity and the timescales of other mechanisms that can either allow the disk material to accrete or disperse are longer (of order 10 Myr) than the the timescales on which planets can form.
Once the planets are formed there is no reason at all that their orbits should shrink, since once the gas/dust of the disk is removed/accreted, there are no effective processes to remove their angular momentum.