It is interesting that two cultures with contrasting religions would share a similar story. In this case, it is the flood story from the Bible's Genesis and Epic of Gilgamesh. Could two radically different backgrounds have the same reason to preserve the same story? Both stories involve mankind being punished severely, having to unknowingly forfeit their lives to a torrent at the whim of their respective gods. Meanwhile there's only a chosen survivor, his family, and a pair of animals of each sex from diverse groups to board a boat in order to escape the flood.
Both flood stories, even with the same plot elements, ironically have multiple differences, many of them religiously based. In Gilgamesh, Enlil released the flood because of the "clamour" caused by the (even then) "[teeming]" population of mankind and is later chastised for his actions by Utnapishtim and another god, Ea. There is even a beautiful verse recited by Ea "lay upon the (individual) sinner his sin..." Whereas, god from Genesis, being omnipotent and supposedly having just motive, doesn't warrant even a mention of second thoughts or questioning from Noah (at least not in this edition), the closest being god's proclamation that the waters "shall no more become a flood to destory all flesh." Also, while Noah does live for many centuries, he does receive immortality like Utnapishtim since his story is monotheistic.
In Genesis the flood lasts 40 days and Noah checks the global status every 7 days with the help of a raven and 3 doves. While the time period of the destruction in Gilgamesh lasted for 6 days and nights and on the 7th day, a dove is released to check the status of the world, then afterwards a swallow and a raven (but whether it was every 7 days or on the same day is unclear). Narration in Gilgamesh is 1st person by the hero, while in Genesis, it's third person, making the first much much more complex than the latter since the readers get a glimpse into the thoughts and emotions of Utnapishtim, when having to leave behind his people and city to conditions beyond his control.
Going back to the reason each version of the similar story is preserved... Perhaps both cultures believed in the flood and there was an Utnapishtim and Noah. Even though the flood in Gilgamesh wasn't agreed upon by all, perhaps both stories still were meant to serve as a reminder for mankind not to provoke the wrath of the gods, since there is no telling what is going to happen. Like 2012...