The Purpose of the World — Experience and Liberation
Patanjali teaches that Prakriti (the world of experience) has two purposes: to provide experience (bhoga) to the soul, and ultimately to facilitate the soul's liberation (apavarga) — the entire universe exists in service of consciousness's journey home.
Sutra 2.18 states that the seen world exists for two purposes: bhoga (experience — including both pleasure and pain, which educate consciousness) and apavarga (liberation — the ultimate release from conditioned experience). This teleological framework makes every experience — however painful — meaningful: it is part of consciousness educating itself about its own nature by experiencing what it is not. The universe is not hostile to consciousness but is, in the deepest sense, in service to it. Pain teaches discrimination; pleasure teaches about the impermanence of gratification; both ultimately lead the genuinely sincere seeker toward the recognition that what they truly seek cannot be found in any object of experience. The world is a school, every experience a lesson, and liberation is graduation.
The seen world exists for the purpose of experience and liberation of the Seer.
Ken Wilber's Integral Philosophy develops the most comprehensive modern framework for Patanjali's teleological view — arguing that evolution itself is Prakriti's movement toward greater consciousness, with the individual spiritual journey as a microcosm of the cosmos's own awakening.
Yoga Sutras of Patanjali