Bhagavan Shri Krishna said: I disclosed this imperishable knowledge of yoga unto Vivasvan, the sun-god. He then taught it to Vaivasvata Manu, who then instructed the same knowledge to Ikshvaku.
Bhagavad Gita - Chapter 4 - Jnana Yoga - The Yoga of Knowledge
In this way, O conqueror of the enemy, the pious rulers understood this path of knowledge through the disciplic succession. However, this knowledge of yoga has been lost due to the influence of time.
I am again teaching this ancient science of yoga to you. Because you are My dear friend and devotee you can understand the transcendental mystery of which I speak.
Arjuna said: You were born only recently and the sungod appeared long ago. So how am I to understand that in ancient times You had taught him the science of yoga?
Bhagavan Shri Krishna said: O conqueror of the enemy, both you and I have passed through many births. I know all of them but you do not.
You should know that although I am the Creator, Controller and Master of all that be and I appear to take birth, I am not actually born. I appear in this universe every millennium in My original spiritual form that never deteriorates.
O descendent of Bharata, whenever there is a decline in dharma and a rise of adharma, I personally appear.
To protect the pious living beings and to put an end to malevolence, I appear in every age to establish dharma.
One who understands My divine appearance and activities never takes birth again after giving up this material body. He comes to Me, O Arjuna.
Freed from mundane attachment, fear and anger and absorbed in thinking of Me, many people have taken refuge in Me and become purified by the knowledge of austerity and attained love for Me.