Enkidu has been created by a goddess to be a moral check on Gilgamesh. Gilgamesh is half-immortal, created by the goddess Aruru.
In the beginning of the epic, Gilgamesh is acting quite badly, to say the least. The people cry out for help; the gods hear them and tell the goddess: "you made him, O Aruru, now create his equal; let it be as like him as his own reflection, his second self, stormy heart for stormy heart. Let them contend together and leave Uruk in quiet."
Enkidu acts as both interpreter of dreams and as an oracle. He interprets a dream of a wild bull for Gilgamesh in Part 2, telling him that they will soon face peril but will be delivered. He is correct. Gilgamesh comes to rely on Ekindu more and more.
But then Ekindu has a dream after they have killed the Bull of Heaven and Humbaba. His dream predicts that because of their actions, one of the two must die.
His dream proves true. Enkidu is killed. Gilgamesh feels adrift without the moral compass of Enkidu