The Solar System is expected to have formed within a cluster of stars containing roughly 1,000 to 10,000 members. Planet Nine is likely to be ejected if the Sun had resided within its natal cluster for longer than ~100 million years. After the Sun had drifted out of its natal cluster, the probability of Planet Nine being ejected from the Solar System due to interactions with passing field stars is only ~3 percent over the age of the Sun. Finally, Planet Nine could be a planet that was captured from another star or it could be a captured free-floating planet. However, both these scenarios have relatively low probabilities.
Reference:
Li & Adams (2016), "Interaction Cross Sections and Survival Rates for Proposed Solar System Member Planet Nine", arXiv:1602.08496 [astro-ph.EP]