Enkidu acts as a foil to Gilgamesh. What do you learn about Gilgamesh's strengths and weaknesses in looking at his relationship to Enkidu?
A foil in literature is a character that is used to illuminate the strengths and weaknesses of another through the two characters' similarities and differences. This is true of Enkidu and Gilgamesh.
In the first place, they act as foils to each other in terms of their backgrounds and genetic compositions—Gilgamesh is two thirds divine and was raised in a civilized environment, which highlights the often uncivilized behavior of Enkidu, who was raised in the wild and is human. In this way, the characters' disparate backgrounds tell us about the weaknesses in Enkidu's social comportment.
In personality, the two are also contrasts. Enkidu could be perceived as cowardly by contrast to Gilgamesh, who is hungry for battle, but in fact we see that Enkidu's wisdom is a very necessary temper to Gilgamesh's impulsiveness. Enkidu has the forethought to recognize that fighting Humbaba will end badly, whereas Gilgamesh is driven by his desire for full immortality to behave recklessly.
In the anonymous epic of Gilgamesh, Enkidu serves as a moral compass for the young ruler of Uruk. Gilgamesh, as we first see him, is an example of absolute rule untempered by any sense of responsibility. He cares for no one but himself and nothing but his own pleasure. Enkidu, with his close connections with gods and nature, has not been corrupted by luxury. He is described in Tablet VIII:
Enkidu, . . . your mother is a gazelle,
and . . . your father who created you, a wild ass.
[You were] raised by creatures with tails,
and by the animals of the wilderness, with all its breadth.
In his friendship for Enkidu, and his mourning at the loss of Enkidu, Gilgamesh gradually develops a sense of empathy with his subjects and attitude of responsibility as a ruler. His experience with undergoing suffering and deprivation and his understanding of mortality in his quest after the death of his friend make him a wiser and juster king.
Throughout much of Gilgamesh's journey, we can see that, like any other human, this king has flaws and desires. One of his main desires, as the son of both a human and a god, is to find a way to reach immortality. (His mom was the minor goddess Ninsun, and his father was a King, and somehow this adds up to him being 2/3 god, and still mortal. Don't look at me, I didn't do that math.) In fact, we see a lot of rage from Gilgamesh toward the fact that he is mortal. As the King of Uruk, he is a terrible ruler—so focused on himself and his desires that essentially nothing else matters. He is disrespectful, violent, and apathetic.
Usually, when we in the modern day think of heroes, we think of the good guys, selflessly putting their lives on the line for others. Gilgamesh is a literary "hero" because he goes on a journey that has many of the classic elements of a literary hero's journey (meeting with a goddess, supernatural aid, etc.). When we say Gilgamesh is a hero, we don't mean that he's a good guy. At least, not until he meets Enkidu.
In fact, Enkidu was specifically made by the gods in order to help get rid of Gilgamesh's selfish and arrogant ways. For most of his life before he meets Gilgamesh, he has been kept away from people, living in the wilderness, and therefore hasn't had the chance to become wicked or selfish like other people.
From his relationship with Enkidu, we see some of Gilgamesh's weaknesses disappear and become replaced with strengths. Throughout his journey, we see Gilgamesh demonstrate strength in the form of literal physical strength, but a loving friendship teaches Gilgamesh compassion and empathy, and Enkidu's death causes him to work to eventually accept the fact that he is mortal. Over the course of his friendship with Enkidu, we see Gilgamesh's transformation from a demigod terrible to behold to a man with limitations, just like anyone else.