Mahabharata shows the different characters as a mixture of good and bad. This is why Duryodhana is shown in heaven for a little while, and the Pandavas in hell for a little while.
Om! Having bowed down into Narayana, and to Nara, the foremost of men,
as also to the goddess Sarasvati, should the word "Jaya" be uttered.
Janamejaya said, "Having attained to Heaven, what regions were
respectively attained by my grandsires of old, viz., the Pandavas and
the sons of Dhritarashtra? I desire to hear this. I think that thou
art conversant with everything, having been taught by the great Rishi
Vyasa of wonderful feats.
Vaishampayana said, "Listen now to what thy grandsires, Yudhishthira
and others, did after having attained to Heaven, that place of the
deities. Arrived at Heaven, king Yudhishthira the just, beheld
Duryodhana endued with prosperity and seated on an excellent seat. He
blazed with effulgence like the sun and wore all those signs of glory
which belong to heroes. And he was in the company of many deities of
blazing effulgence and of Sadhyas of righteous deeds. Yudhishthira,
beholding Duryodhana and his prosperity, became suddenly filled with
rage and turned back from the sight.
"He loudly addressed his companions, saying, ‘I do not desire to share
regions of felicity with Duryodhana who was stained by cupidity and
possessed of little foresight. It was for him that friends, and
kinsmen, over the whole Earth were slaughtered by us whom he had
afflicted greatly in the deep forest. It was for him that the virtuous
princess of Pancala, Draupadi of faultless features, our wife, was
dragged into the midst of the assembly before all our seniors. Ye
gods, I have no desire to even behold Suyodhana. I wish to go there
where my brothers are.’
"Narada, smiling, told him, ‘It should not be so, O king of kings.
While residing in Heaven, all enmities cease. O mighty-armed
Yudhishthira, do not say so about king Duryodhana. Hear my words. Here
is king Duryodhana. He is worshipped with the gods by those righteous
men and those foremost of kings who are now denizens of Heaven. By
causing his body to be poured as a libation on the fire of battle, he
has obtained the end that consists in attainment of the region for
heroes. You and your brothers, who were veritable gods on Earth, were
always persecuted by this one. Yet through his observance of Kshatriya
practices he has attained to this region. This lord of Earth was not
terrified in a situation fraught with terror.
"‘O son, thou shouldst not bear in mind the woes inflicted on thee on
account of the match at dice. It behoveth thee not to remember the
afflictions of Draupadi. It behoveth thee not to remember the other
woes which were yours in consequence of the acts of your kinsmen,—the
woes, viz., that were due to battle or to other situations. Do thou
meet Duryodhana now according to the ordinances of polite intercourse.
This is Heaven, O lord of men. There can be no enmities here.’
"Though thus addressed by Narada, the Kuru king Yudhishthira, endued
with great intelligence, enquired about his brothers and said, ‘If
these eternal regions reserved for heroes be Duryodhana’s, that
unrighteous and sinful wight, that man who was the destroyer of
friends and of the whole world, that man for whose sake the entire
Earth was devastated with all her horses and elephants and human
beings, that wight for whose sake we were burnt with wrath in thinking
of how best we might remedy our wrongs, I desire to see what regions
have been attained by those high-souled heroes, my brothers of high
vows, steady achievers of promises, truthful in speech, and
distinguished for courage. The high-souled Karna, the son of Kunti,
incapable of being baffled in battle, Dhrishtadyumna, Satyaki, the
sons of Dhrishtadyumna and those other Kshatriyas who met with death
in the observance of Kshatriya practices, where are those lords of
Earth, O Brahmana? I do not see them here, O Narada. I desire to see,
O Narada, Virata and Drupada and the other great Kshatriyas headed by
Dhrishtaketu, as also Shikhandi, the Pancala prince, the sons of
Draupadi, and Abhimanyu, irresistible in battle.’
Mahabharata Svargarohanika Parva, Section I
This is not the end of the story. Duryodhana would also have to endure hell after staying in heaven for all the bad things he has done. Duryodhan first stays in heaven and then hell because his sinful acts are many. Similarly Pandavas would end up in heaven after hell because of their good acts.
Vaishampayana said, "King Yudhishthira the just, the son of Pritha,
had not stayed there for more than a moment when, O thou of Kuru’s
race, all the gods with Indra at their head came to that spot. The
deity of Righteousness in his embodied form also came to that place
where the Kuru king was, for seeing that monarch. Upon the advent of
those deities of resplendent bodies and sanctified and noble deeds,
the darkness that had overwhelmed that region immediately disappeared.
The torments undergone by beings of sinful deeds were no longer seen.
The river Vaitarani, the thorny Salmali, the iron jars, and the
boulders of rock, so terrible to behold, also vanished from sight. The
diverse repulsive corpses also, which the Kuru king had seen,
disappeared at the same time. Then a breeze, delicious and fraught
with pleasant perfumes, perfectly pure and delightfully cool, O
Bharata, began to blow on that spot in consequence of the presence of
the gods. The Maruts, with Indra, the Vasus with the twin Ashvinis,
the Sadhyas, the Rudras, the Adityas, and the other denizens of
Heaven, as also the Siddhas and the great Rishis, all came there where
Dharma’s royal son of great energy was.
"Then Shakra, the lord of the deities, endued with blazing prosperity,
addressed Yudhishthira and comforting him, said, ‘O Yudhishthira of
mighty arms, come, come, O chief of men. These illusions have ended, O
puissant one. Success has been attained by thee, O mighty-armed one,
and eternal regions (of felicity) have become thine. Thou shouldst not
yield to wrath. Listen to these words of mine. Hell, O son, should
without doubt be beheld by every king. Of both good and bad there is
abundance, O chief of men. He who enjoys first the fruits of his good
acts must afterwards endure Hell. He, on the other hand, who first
endures Hell, must afterwards enjoy Heaven. He whose sinful acts are
many enjoys Heaven first. It is for this, O king, that desirous of
doing thee good, I caused thee to be sent for having a view of Hell.
Thou hadst, by a pretence, deceived Drona in the matter of his son.
Thou hast, in consequence thereof, been shown Hell by an act of
deception. After the manner of thyself, Bhima and Arjuna, and
Draupadi, have all been shown the place of sinners by an act of
deception. Come, O chief of men, all of them have been cleansed of
their sins. All those kings who had aided thee and who have been slain
in battle, have all attained to Heaven. Come and behold them, O
foremost one of Bharata’s race.
Mahabharata Svargarohanika Parva Section III
Now I will answer the three specific questions asked in the comments.
Question 1: I wanted to know why the gods were so partial with the Pandavas? Without their assistance the Pandavas would have also become like the Kauravas.
The short answer is that the Kauravas were more in the wrong than the Pandavas. In fact Lord Krishna has given an answer to this question.
Krishna’s admonition to Duryodhana
Duryodhana began to afflict Vasudeva with keen and bitter words, "O
son of Kansa's slave, thou hast, it seems, no shame, for hast thou
forgotten that I have been struck down most unfairly, judged by the
rules that prevail in encounters with the mace? It was thou who
unfairly caused this act by reminding Bhima with a hint about the
breaking of my thighs! Dost thou think I did not mark it when Arjuna
(acting under thy advice) hinted it to Bhima? Having caused thousands
of kings, who always fought fairly, to be slain through diverse kinds
of unfair means, feelest thou no shame or no abhorrence for those
acts? Day after day having caused a great carnage of heroic warriors,
thou causedst the grandsire to be slain by placing Shikhandi to the
fore! Having again caused an elephant of the name of Ashvatthama to be
slain, O thou of wicked understanding, thou causedst the preceptor to
lay aside his weapons. Thinkest thou that this is not known to me!
While again that valiant hero was about to be slain this cruel
Dhrishtadyumna, thou didst not dissuade the latter! The dart that had
been begged (of Shakra as a boon) by Karna for the slaughter of Arjuna
was baffled by thee through Ghatotkacha! Who is there that is more
sinful than thou? Similarly, the mighty Bhurishrava, with one of his
arms lopped off and while observant of the Praya vow, was caused to be
slain by thee through the agency of the high-souled Satyaki. Karna had
done a great feat for vanquishing Partha. Thou, however, causedst
Aswasena, the son of that prince of snakes (Takshaka), to be baffled
in achieving his purpose! When again the wheel of Karna's car sank in
mire and Karna was afflicted with calamity and almost vanquished on
that account, when, indeed, that foremost of men became anxious to
liberate his wheel, thou causedst that Karna to be then slain! If ye
had fought me and Karna and Bhishma and Drona by fair means, victory
then, without doubt, would never have been yours. By adopting the most
crooked and unrighteous of means thou hast caused many kings observant
of the duties of their order and ourselves also to be slain!'
"'Vasudeva said, "Thou, O son of Gandhari, hast been slain with thy
brothers, sons, kinsmen, friends, and followers, only in consequence
of the sinful path in which thou hast trod! Through thy evil acts
those two heroes, Bhishma and Drona, have been slain! Karna too hath
been slain for having imitated thy behaviour! Solicited by me, O fool,
thou didst not, from avarice, give the Pandavas their paternal share,
acting according to the counsels of Shakuni! Thou gavest poison to
Bhimasena! Thou hadst, also, O thou of wicked understanding,
endeavoured to burn all the Pandavas with their mother at the palace
of lac! On the occasion also of the gambling, thou hadst persecuted
the daughter of Yajnasena, while in her season, in the midst of the
assembly! Shameless as thou art, even then thou becamest worthy of
being slain! Thou hadst, through Subala's son well-versed in dice,
unfairly vanquished the virtuous Yudhishthira who was unskilled in
gambling! For that art thou slain! Through the sinful Jayadratha
again, Krishna was on another occasion persecuted when the Pandavas,
her lords, had gone out hunting towards the hermitage of Trinavindu!
Causing Abhimanyu, who was a child and alone, to be surrounded by
many, thou didst slay that hero. It is in consequence of that fault, O
sinful wretch, that thou art slain! All those unrighteous acts that
thou sayest have been perpetrated by us, have in reality been
perpetrated by thee in consequence of thy sinful nature! Thou didst
never listen to the counsels of Brihaspati and Usanas! Thou didst
never wait upon the old! Thou didst never hear beneficial words!
Enslaved by ungovernable covetousness and thirst of gain, thou didst
perpetrate many unrighteous acts! Bear now the consequences of those
acts of thine!"
Mahabharata Shalya Parva Section 61
Question 2: Pandavas also had a tendency to defame anyone who tried to be better than them eg- karna, Ekalavya etc. so why only they are considered as the unbeatable warriors. The epic has shown that whatever is done only glory to Pandavas , everyone else who are not with them adharmi. I highly doubt even if lord Rama , hanuman, shiva were present in a disguised from in Mahabharata, they would have also been criticised by the Pandavas.
Mahabharata does not portray Pandavas as perfect. For example, in the Ekalavya episode Mahabharata says that Arjuna was jealous. Mahabharata does not portray Pandavas as unbeatable. Pandavas except for Yudhisthira were killed in several episodes in Mahabharata. Pandavas had to go to hell for their imperfect nature.
Vaisamapyana continued, “On hearing these words, Drona reflected for a
moment, and resolving upon the course of action he would follow, took
Arjuna with him and went unto the Nishada prince.And he beheld
Ekalavya with body besmeared with filth, matted locks (on head), clad
in rags, bearing a bow in hand and ceaselessly shooting arrows
therefrom. And when Ekalavya saw Drona approaching towards him, he
went a few steps forward, and touching his feet and prostrated himself
on the ground. And the son of the Nishada king worshipping Drona, duly
represented himself as his pupil, and clasping his hands in reverence
stood before him (awaiting his commands). Then Drona, O king,
addressed Ekalavya, saying, ‘If, O hero, thou art really my pupil,
give me then my fees.’ On hearing these words, Ekalavya was very much
gratified, and said in reply, ‘O illustrious preceptor, what shall I
give? Command me; for there is nothing, O foremost of all persons
conversant with the Vedas, that I may not give unto my preceptor.’
Drona answered, ‘O Ekalavya, if thou art really intent on making a
gift, I should like then to have the thumb of thy right hand.’
Vaisampayana continued, ”Hearing these cruel words of Drona, who had
asked him of his thumb as tution-fee, Ekalavya, ever devoted to truth
and desirous also of keeping his promise, with a cheerful face and an
unafflicted heart cut off without ado his thumb, and gave it unto
Drona. After this, when the Nishada prince began once more to shoot
with the help of his remaining fingers, he found, O king, that he had
lost his former lightness of hand. And at this Arjuna became happy,
the fever (of jealousy) having left him.
Mahabharata, Adi Parva, Section CXXXIV
Question 3: Karna was punished for getting knowledge by deceit, but I ask, what is so discriminatory about knowledge that it should be given to some and not to others. Arjuna did not have to worry for the assistance in knowledge, but for anyone else getting quality knowledge is prohibited. Isn’t it same as the caste system without any virtue?
You are right that a great injustice was done to Karna. The reader of Mahabharata is not supposed to support the action of the characters. Some of the characters tried to disrobe Draupadi. Does this mean Mahabharata is asking all the readers to disrobe women? Mahabharata, in fact, warns the reader to accept any scriptural text at face value.
Even the words heard from an ignorant person, if in themselves they be
fraught with sense, come to be regarded as pious and wise. In days of
old, Usanas said unto the Daityas this truth, which should remove all
doubts, that scriptures are no scriptures if they cannot stand the
test of reason.
Mahabharata Shanti Parva Section CXLII
Question 4: 'Whereas the pandavas were always shown as the glorious one. If only pandavas too had some failures like kauravas then the epic would have been rational'. Are Pandavas always shown as successful?
The answer is no. Arjuna had a shameful defeat in the hands of robbers.
"After all the people had set out, the ocean, that home of sharks and
alligators, flooded Dvaraka, which still teemed with wealth of every
kind, with its waters. Whatever portion of the ground was passed over,
ocean immediately flooded over with his waters. Beholding this
wonderful sight, the inhabitants of Dvaraka walked faster and faster,
saying, ‘Wonderful is the course of fate!’ Dhananjaya, after
abandoning Dvaraka, proceeded by slow marches, causing the Vrishni
women to rest in pleasant forests and mountains and by the sides of
delightful streams. Arrived at the country of the five waters, the
puissant Dhananjaya planted a rich encampment in the midst of a land
that abounded with corn and kine and other animals. Beholding those
lordless widows escorted by Pritha’s son alone O Bharata, the robbers
felt a great temptation (for plunder). Then those sinful wretches,
with hearts overwhelmed by cupidity, those Abhiras of ill omen,
assembled together and held a consultation. They said, ‘Here there is
only one bowman, Arjuna. The cavalcade consists of children and the
old. He escorts them, transgressing us. The warriors (of the Vrishnis)
are without energy.’ Then those robbers, numbering by thousands, and
armed with clubs, rushed towards the procession of the Vrishnis,
desirous of plunder. Urged by the perverse course of time they fell
upon that vast concourse, frightening it with loud leonine shouts and
desirous of slaughter. The son of Kunti, suddenly ceasing to advance
along the path, turned, with his followers, towards the place where
the robbers had attacked the procession. Smiling the while, that
mighty-armed warrior addressed the assailants, saying, ‘You sinful
wretches, forbear, if ye love your lives. Ye will rue this when I
pierce your bodies with my shafts and take your lives.’ Though thus
addressed by that hero, they disregarded his words, and though
repeatedly dissuaded, they fell upon Arjuna. Then Arjuna endeavoured
to string his large, indestructible, celestial bow with some effort.
He succeeded with great difficulty in stringing it, when the battle
had become furious. He then began to think of his celestial weapons
but they would not come to his mind. Beholding that furious battle,
the loss of the might of his arm, and the non-appearance of his
celestial weapons, Arjuna became greatly ashamed. The Vrishni warriors
including the foot-soldiers, the elephant-warriors, and the car-men,
failed to rescue those Vrishni women that were being snatched away by
the robbers. The concourse was very large. The robbers assailed it at
different points. Arjuna tried his best to protect it, but could not
succeed. In the very sightof all the warriors, many foremost of ladies
were dragged away, while others went away with the robbers of their
own accord. The puissant Arjuna, supported by the servants of the
Vrishnis, struck the robbers with shafts sped from Gandiva. Soon,
however. O king, his shafts were exhausted. In former days his shafts
had been inexhaustible. Now, however, they proved otherwise. Finding
his shafts exhausted, he became deeply afflicted with grief. The son
of Indra then began to strike the robbers with the horns of his bow.
Those Mlecchas, however, O Janamejaya, in the very sight of Partha,
retreated, taking away with them many foremost ladies of the Vrishnis
and Andhakas. The puissant Dhananjaya regarded it all as the work of
destiny. Filled with sorrow he breathed heavy sighs at the thought of
the non-appearance of his (celestial) weapons, the loss of the might
of his arms, the refusal of his bow to obey him, and the exhaustion of
his shafts. Regarding it all as the work of destiny, he became
exceedingly cheerless. He then ceased, O king, to make further
efforts, saying, he had not the power which he had before. The
high-souled one, taking with him the remnant of the Vrishni women, and
the wealth that was still with them, reached Kurukshetra. Thus
bringing with him the remnant of the Vrishnis. he established them at
different places. He established the son of Kritavarma at the city
called Marttikavat, with the remnant of the women of the Bhoja king.
Escorting the remainder, with children and old men and women, the son
of Pandu established them, who were reft of heroes, in the city of
Indraprastha. The dear son of Yuyudhana, with a company of old men and
children and women, the righteous-souled Arjuna established on the
banks of the Sarasvati. The rule of Indraprastha was given to Vajra.
The widows of Akrura then desired to retire into the woods. Vajra
asked them repeatedly to desist, but they did not listen to him.
Rukmini, the princess of Gandhara, Saivya, Haimavati, and queen
Jamvabati ascended the funeral pyre. Satyabhama and other dear wives
of Krishna entered the woods, O king, resolved to set themselves to
the practice of penances. They began to live on fruits and roots and
pass their time in the contemplation of Hari. Going beyond the
Himavat, they took up their abode in a place called Kalpa. Those men
who had followed Arjuna from Dwaravati, were distributed into groups,
and bestowed upon Vajra. Having done all these acts suited to the
occasion, Arjuna, with eyes bathed in tears, then entered the retreat
of Vyasa. There he beheld the Island-born Rishi seated at his ease."
Mahabharata, Mausala Parva, Section 7
Mahabharata is not asking the reader to behave exactly like the characters in the text. Instead the reader is asked to use his reason to evaluate the characters and behave accordingly.