Rocky cores near sun become terrestrial planets. Further from sun rocky cores accrete more ices and grow to giant proportions. But the process continues at a slower pace. Initially remaining material is swept up by existing planets, slowing the process still further. This shows up as intense cratering of planets.
Comets are leftover material.
Asteroids may have been kept from accreting by Jupiter's great tidal force. Probably a combination of events. Origin of the Solar System by Frank Crary Origin of the Solar System from Univ of Pittsburgh.