In the Ramayana Rama is described as a model son whose entire life is guided by the Hindu principle of Dharma. Dharma corresponds to the Chinese Tao or Western philosophy's “law of nature” which believes an ultimate reality based on law and harmony in the universe calls for certain actions of right conduct. A hero is often forced to go on a quest for the common good or perform an action of Dharma that appears to be counter to self-interest. This means giving up comfort and security in favor of one's duty. Rama's duty, and hence, his Dharma, is to accept the authority of his father and the rule of law rather then assert his own interest.
Gilgamesh, on the other hand, is on a quest for something that is frankly contrary to the laws of nature and Dharma: physical immortality. In the end Gilgamesh sees that his quest is futile and that he has been fighting against order and the laws of the universe. Belatedly, Gilgamesh understands that his duty is not to seek after physical immortality but to be the leader of his people for the time he is alive.
In the Ramayana the moral virtue of Rama is also praised. His exemplary life wins him the respect of his father the king and all his peers. The grief and sadness they experience at his exile testifies to the goodness they see in him. By contrast, the hero's nemesis Ravana is a villain because,
The bonds of law and right he spurned:
To others’ wives his fancy turned. (Valmiki 394).
Interestingly enough, this description of a villain in the Ramayana is remarkable similar to the description of Gilgamesh. The Epic of Gilgamesh records that Gilgamesh,
Has altered the unaltered way,
Abused, changed the practices.
Any new bride from the people is his (Epic of Gilgamesh).
Clearly, when it comes to morality--respecting the rights of other people--Gilgamesh falls far short of the heroic ideal set by Rama.
Gilgamesh cannot match Rama's adherence to the duty inherent in the order of the universe nor can he match Rama's moral virtue. Gilgamesh fights against the order of the universe presented in The Epic of Gilgamesh that asserts a man cannot attain physical immortality. Also, his selfish and arrogant behavior demeans his otherwise remarkable exploits. In contrast, Rama, through his adherence to Dharma, fights on the side of order and righteousness. He sets a heroic example of selflessness and duty. Prince Rama is endowed with heroic virtues whose ultimate worth far exceeds those of arrogant Gilgamesh.
The Epic of Gilgamesh. Trans. Robert Temple. Tablet II “Gateways To Babylon” http://www.angelfire.com/tx/gatestobabylon/temple1.html
Valmiki, The Ramayana of Valmiki. Trans. Ralph T. H. Griffith. Project Gutenberg. http://www.gutenberg.org/etext/24869