Why do the Bible and the Epic of Gilgamesh both contain a story about a flood?Which was written first?
A definitive answer to this question is not possible, of course, because we do not always know the motives of the authors of these works, or, for that matter, who the authors were. We also lack a complete geological or archaeological record. But two possibilities come to mind.
First, there is a kind of theme in both about God or the gods have not done very well with mankind and having a need to wipe the slate clean and start over. This is clear in the Bible, but more implicit in Gilgamesh. Thus the point of both stories seems to be that mankind had better get its act together!
Second, while the record is not clear, there is some evidence to suggest that a flood may have occurred somewhere in that part of the world. Since I am neither a geologist nor an archaeologist, it is difficult for me to assess this evidence. If you decide to do research on this issue, you should be aware that many websites discussing the issue are motivated by a need to "prove" the Bible, which, as a religious undertaking, requires belief, not proof.
What a good question. You are right there are these two stories of floods. In fact, there is a few more. For example, the Roman poet, Ovid, has another flood story. It is fairly close to the Biblical story. There are two people who find favor with the gods and they are the sole survivors. Their names are Deucalion and Phyrra. Now the question is why these flood narratives exist. I would say that there is a simple answer to this that might sound far fetched, but if we use the principle of Occam's razor, the simplest answer should be preferred. When we do this, there is one conclusion. There was actually a flood that took place and that these stories are various strands that reflect the past reality of it.
The Epic of Gilgamesh is believed to have been written somewhere around 2000 BC. The first books of the Old Testament are said to have been written a few hundred years after that.
So why do they both have flood stories? That's the subject of a lot of debate. A creationist/Biblical literalist would say it's because there really was a flood. A skeptic would say it's because floods were an important part of life back then -- being destructive but also bringing life.
There is some speculation that there was a huge flood that created the Black Sea about 9500 years ago. Believers in that theory speculate that both stories come from ancestral memories of that flood.