You have only given part of the story. Swami Vivekananda tells the story of Jada Bharata in the following way (Complete Works, V4, pp 111-114; available here under the heading Lectures and Discourses, sub-heading The Story of Jada Bharata - http://cwsv.belurmath.org/volume_4/vol_4_frame.htm):
There was a great monarch named Bharata. The land which is called India by foreigners is known to her children as Bhârata Varsha. Now, it is enjoined on every Hindu when he becomes old, to give up all worldly pursuits — to leave the cares of the world, its wealth, happiness, and enjoyments to his son — and retire into the forest, there to meditate upon the Self which is the only reality in him, and thus break the bonds which bind him to life. King or priest, peasant or servant, man or woman, none is exempt from this duty: for all the duties of the householder — of the son, the brother, the husband, the father, the wife, the daughter, the mother, the sister — are but preparations towards that one stage, when all the bonds which bind the soul to matter are severed asunder for ever.
The great king Bharata in his old age gave over his throne to his son, and retired into the forest. He who had been ruler over millions and millions of subjects, who had lived in marble palaces, inlaid with gold and silver, who had drunk out of jewelled cups — this king built a little cottage with his own hands, made of reeds and grass, on the banks of a river in the Himalayan forests. There he lived on roots and wild herbs, collected by his own hands, and constantly meditated upon Him who is always present in the soul of man. Days, months, and years passed. One day, a deer came to drink water near by where the royal sage was meditating. At the same moment, a lion roared at a little distance off. The deer was so terrified that she, without satisfying her thirst, made a big jump to cross the river. The deer was with young, and this extreme exertion and sudden fright made her give birth to a little fawn, and immediately after she fell dead. The fawn fell into the water and was being carried rapidly away by the foaming stream, when it caught the eyes of the king. The king rose from his position of meditation and rescuing the fawn from the water, took it to his cottage, made a fire, and with care and attention fondled the little thing back to life. Then the kindly sage took the fawn under his protection, bringing it up on soft grass and fruits. The fawn thrived under the paternal care of the retired monarch, and grew into a beautiful deer. Then, he whose mind had been strong enough to break away from lifelong attachment to power, position, and family, became attached to the deer which he had saved from the stream. And as he became fonder and fonder of the deer, the less and less he could concentrate his mind upon the Lord. When the deer went out to graze in the forest, if it were late in returning, the mind of the royal sage would become anxious and worried. He would think, "Perhaps my little one has been attacked by some tiger — or perhaps some other danger has befallen it; otherwise, why is it late?"
Some years passed in this way, but one day death came, and the royal sage laid himself down to die. But his mind, instead of being intent upon the Self, was thinking about the deer; and with his eyes fixed upon the sad looks of his beloved deer, his soul left the body. As the result of this, in the next birth he was born as a deer. But no Karma is lost, and all the great and good deeds done by him as a king and sage bore their fruit. This deer was a born Jâtismara, and remembered his past birth, though he was bereft of speech and was living in an animal body. He always left his companions and was instinctively drawn to graze near hermitages where oblations were offered and the Upanishads were preached.
After the usual years of a deer's life had been spent, it died and was next born as the youngest son of a rich Brahmin. And in that life also, he remembered all his past, and even in his childhood was determined no more to get entangled in the good and evil of life. The child, as it grew up, was strong and healthy, but would not speak a word, and lived as one inert and insane, for fear of getting mixed up with worldly affairs. His thoughts were always on the Infinite, and he lived only to wear out his past Prârabdha Karma. In course of time the father died, and the sons divided the property among themselves; and thinking that the youngest was a dumb, good-for-nothing man, they seized his share. Their charity, however, extended only so far as to give him enough food to live upon. The wives of the brothers were often very harsh to him, putting him to do all the hard work; and if he was unable to do everything they wanted, they would treat him very unkindly. But he showed neither vexation nor fear, and neither did he speak a word. When they persecuted him very much, he would stroll out of the house and sit under a tree, by the hour, until their wrath was appeased, and then he would quietly go home again.
One day; when the wives of the brothers had treated him with more than usual unkindness, Bharata went out of the house, seated himself under the shadow of a tree and rested. Now it happened that the king of the country was passing by, carried in a palanquin on the shoulders of bearers. One of the bearers had unexpectedly fallen ill, and so his attendants were looking about for a man to replace him. They came upon Bharata seated under a tree; and seeing he was a strong young man, they asked him if he would take the place of the sick man in bearing the king's palanquin. But Bharata did not reply. Seeing that he was so able-bodied, the king's servants caught hold of him and placed the pole on his shoulders. Without speaking a word, Bharata went on. Very soon after this, the king remarked that the palanquin was not being evenly carried, and looking out of the palanquin addressed the new bearer, saying "Fool, rest a while; if thy shoulders pain thee, rest a while." Then Bharata laying the pole of the palanquin down, opened his lips for the first time in his life, and spoke, "Whom dost thou, O King, call a fool? Whom dost thou ask to lay down the palanquin? Who dost thou say is weary? Whom dost thou address as 'thou'? If thou meanest, O King, by the word 'thee' this mass of flesh, it is composed of the same matter as thine; it is unconscious, and it knoweth no weariness, it knoweth no pain. If it is the mind, the mind is the same as thine; it is universal. But if the word 'thee' is applied to something beyond that, then it is the Self, the Reality in me, which is the same as in thee, and it is the One in the universe. Dost thou mean, O King, that the Self can ever be weary, that It can ever be tired, that It can ever be hurt? I did not want, O King — this body did not want — to trample upon the poor worms crawling on the road, and therefore, in trying to avoid them, the palanquin moved unevenly. But the Self was never tired; It was never weak; It never bore the pole of the palanquin: for It is omnipotent and omnipresent." And so he dwelt eloquently on the nature of the soul, and on the highest knowledge, etc. The king, who was proud of his learning, knowledge, and philosophy, alighted from the palanquin, and fell at the feet of Bharata, saying, "I ask thy pardon, O mighty one, I did not know that thou wast a sage, when I asked thee to carry me." Bharata blessed him and departed. He then resumed the even tenor of his previous life. When Bharata left the body, he was freed for ever from the bondage of birth.
The story is meant to convey the message of the scripture (in SwiftPuskar's answer from the Prashna Upanishad and Keshav Srinivasan's answer that quotes the Gita.) What you think of in your final moments determines the push of your soul at death.