Sage Patanjali consolidates the teaching of yoga that was taught orally to what we now as the Patanjali Yoga sutras. These teachings form the 8 limbs of yoga - the Astanga Yoga Sutras.
1. Yama: Correct behavior toward others.
Nonviolence
Truthfulness
Not stealing
Not wasting energy
Abstaining from greed
2. Niyama: The principles by which you should live your own life
Purity
Contentment
Spiritual observances
Study
Devotion
3. Asana: The seat of consciousness; the yogi’s seat and postures to prepare the body.
4. Pranayama: Expanding the life force through breathing exercises.
5. Pratyahara: Turning the senses inward to explore the inner universe.
6. Dharana: Effortless focused attention; training the mind to meditate.
7. Dhyana: A continuous flow, meditation perfected.
8. Samadhi: Union with the Self
The first four yamas prepare the body for the next three, which take you to the doorway of the eighth.
Dharana, Dhyana, and Samadhi practiced together is known as Sanyama. Settling the mind, having a subtle intention, and releasing it into the field of Infinite Organizing Power gives you knowledge of the laws of nature of an object and Yogic Powers (Siddhis).
Starting with the way to condition our outlook at life with the Yamas and Niyamas that culture the mind with guides of social interactions, to unraveling the mind and the mental aspects that govern our thoughts and actions hence. Yoga helps one climb from the physical and mental layers of our existence to Jnana and Moksha where one could live in perfect harmony with the Self in bliss, unperturbed by the waves of happiness or sorrows that life brings.
This is summarised in the Chapter 6 Verse 17 of the Bhagavad Gita as:
युक्ताहारविहारस्य युक्तचेष्टस्य कर्मसु | युक्तस्वप्नावबोधस्य योगो भवति दु:खहा || 17||
yuktāhāra-vihārasya yukta-cheṣhṭasya karmasu yukta-svapnāvabodhasya yogo bhavati duḥkha-hā
"He who is moderate in food, activity, entertainment, sleep and mindfullness attains Yoga, that which destroys suffering"
Yoga, which removes suffering, is accomplished by one who is regulated in diet and recreation, regulated in the actions one performs, and regulated in sleep and wakefulness.