The simple answer is the same as for everything else orbiting the Sun — “gravity”. read more
The most likely theory is that the material now in the Oort Cloud probably formed closer to the young Sun in the earliest epochs of solar system formation. As the planets grew, and in particular as Jupiter coalesced and migrated to its present position, its gravitational influence is thought to have scattered many icy objects out to their present position in the Oort cloud. read more