What was the author's purpose in writing "The Epic of Gilgamesh" and who was the intended audience?
The Epic of Gilgamesh has no known author. It is the earliest surviving work of written literature. It is likely that the epic was originally oral stories, passed down from generation to generation as a way to entertain as well as a way to teach values and provide explanation and understanding of the world. Oral stories provided a deep, intimate connection between storyteller and audience and could change between retellings or based on the storyteller's skills and interests. The story may have been written down to preserve it in some way.
As with many epics and mythologies, stories like the Epic of Gilgamesh provide explanation for the natural world and teach values through the stories. One example is Gilgamesh's search for immortality. Distressed about the death of his beloved friend Enkidu, Gilgamesh seeks out eternal life. Dealing with mortality is a very human element in this story and provides a narrative to explore human mortality:
Utnapishtim said to Gilgamesh, "I will reveal to you a mystery. I will tell you a secret of the gods." Life, which you look for, you will never find. For when the gods created man, they let death be his share, and life withheld in their own hands.
This portion of the story serves to explain death.
Additionally, within the same story is the tale of a great flood. This flood is often a theme throughout ancient works, appearing in the Old Testament as well. It is possible it was a world event that humans found divine explanation for as a way for understanding it:
The uproar of mankind is intolerable and sleep is no longer possible by reason of the babel. So the gods agreed to exterminate mankind.
Gilgamesh does not have a known author, but it is the earliest recorded human epic. Only pieces of the story survive and have been cobbled together to form the story of the warrior and Enkindu (the first "sidekick" in recorded history). The intended audience is unknown, but it seems likely that it was an oral tale heard by people of all socio-economic and political backgrounds.
The writer or writers of the epic seems to have several purposes in recounting the tale. It is instructive in explaining events in history: like the Bible, Gilgamesh explains how the world was created (a very interesting comparison can be made between the epic and Genesis 1-3).
Like The Odyssey and Beowulf, texts that come far later, the heroes of each epic battle faces incredible foes (Gilgamesh, Humbaba; Odysseus, the Cyclops; Beowulf, Grendel). The tales of super-human feats seem to be designed to keep the audience in suspense. Each has a hero that is larger-than-life.
There is also an implicit moral in Gilgamesh, a warning about the lust for immortality that will go unsatisfied. Gilgamesh, and those who read of the hero's exploits, must come to terms with their limited selves, strive for acceptance, and hope for remembrance by future generations.
The author/s had several purposes in writing "The Epic of Gilgamesh." One was to express the power of friendship, as Gilgamesh is changed from a brute to a caring leader by his friendship with Enkidu. Similarly, Enkidu learns to become less wild from befriending Gilgamesh. The other moral is that mortals do not have the luxury of everlasting life. While Gilgamesh tries to find the secret to living forever by visiting Utnapushtim, Gilgamesh loses the plant that is supposed to confer everlasting life. Resigning himself to being mortal, Gilgamesh instead turns to being a great king and to achieving what he can on earth, precisely because he knows he is not immortal and that his time on earth is limited. The audience for these lessons were people in ancient Mesopotamia (the later epic was composed around 1300 to 1000 BCE by Sîn-lēqi-unninni, a priest).