Shankaracharya in his Gita Bhasya 18.41 says " Karma is action arising from and fashioned by past thoughts and desires. The Gunas cannot manifest themselves without a cause. Nature is the tendency? Samskara or Vasana in living beings. This is acired by them in the past births. This manifests itself in the present birth and produces its effects." As previously discussed, we see Brahmanas like Aswathamma having noble birth acting in evil way and Vidura born as Sudra and doing noble deeds. People from humble backgrounds like Narendra Modi, APJ Kalam, JC Bose,Sachin Tendulkar rose to greatest intellectual heights despite their parents not perusing these tasks. Then how is Shankaracharya comment justified?
Our current life is totally based on our desires, sanskars, bhakti of our previous life.
We all are stuck in this jail only due to our desires and there desires play a vital role which type of life we will live next.
After the body dies, soul carries sanskars too with him, which help him achieve liberation
And last thing that a soul carries is the devotion and love towards god, that's why people do good deeds for hundreds of lives and then get enlightenment.
Bhagwad Gita, Chapter 8, Verse 13
ओमित्येकाक्षरं ब्रह्म व्याहरन्मामनुस्मरन् | य: प्रयाति त्यजन्देहं स याति परमां गतिम् || 13||
oṁ ityekākṣharaṁ brahma vyāharan mām anusmaran yaḥ prayāti tyajan dehaṁ sa yāti paramāṁ gatim
om ityekaksharam brahma vyaharan mam anusmaran yah prayati tyajan deham sa yati paramam gatim
Meaning:- One who departs from the body while remembering Me, the Supreme Personality, and chanting the syllable Om, will attain the supreme goal.
And at last I want to stay, that in bhagwad geeta also lord krishna said, the thing or person (I.e. desire) a person thinks of at the time of death, gets it without a fail and therefore he also suggests us that if a person is outdated due to his sins and remembers of god at his last moment of life, his all sins are washed off and he receives god without a fail.
I hope you understood the reason Hare Krishna !