At the beginning of the tale, Gilgamesh is a terrible king. He mistreats his subjects and shirks his responsibilities as a ruler. He does not appear to have any close friends or any real purpose to his life. The gods create Enkidu as a friend for Gilgamesh. Their friendship changes Gilgamesh. Enkidu intervenes to prevent Gilgamesh for asserting his right to deflower virgin brides, and causes him to be a better and more just ruler. He also becomes a friend to Gilgamesh and gives him a sense of purpose. Their friendship is so profound as to constitute a form of (nonsexual) love. On the negative side, just as Gilgamesh achieves profound joy in his friendship with Enkidu, he experiences profound sorrow at his death. Nonetheless, the friendship is ultimately beneficial, as it makes Gilgamesh a better person.
From the point of view of Enkidu, he was created by the gods as a friend for Gilgamesh; without that purpose he would not have existed. In the beginning of the story, he is almost as much a beast as a man, living in nature. To a degree his life without Gilgamesh is one of contentment, but it is limited. Since Enkidu does sacrifice his life for Gilgamesh, we could argue that Gilgamesh benefits most from the relationship, but in the cultural context in which the story was written, the fame and deep bond brought by their friendship and shared exploits makes the friendship beneficial overall.