What narrative purpose does the Flood story fulfill? In the Epic of Atrahasis and Epic of Gilgamesh flood myth, the gods are rash, foolish, even weak. 

Genesis copies most of the myth. And although it's sanitized quite a bit, some actions seem to be inconsistent with an all-knowing, all-powerful, all-good God. God decides one moment that all animals must be killed 6:7, and the next that Noah must save them all himself 6:19–20. All humanity is evil and must be purged, except for Noah, but Noah is punished with spending the better part of a year on a tiny boat filled with polar bears. At the end God promises never to try the scheme again 8:21, apparently one step from an outright apology.

What higher narrative purpose does this myth fulfill, that it's included in the Bible despite its extremely subversive origins and troublesome implications?
The narrative purpose of the flood account is actually quite simple. It reminds us of one simple truth of God's character: God is just. 

To the Jew for whom this exact version of the narrative is written (I can leave aside Gilgamesh because it differs in thrust), there is one overwhelming truth- God will punish the wicked. In a world where the wicked often seem to prosper, this is too easily forgotten. To say, the Jews of the exile, this is actually a very comforting thought - that even though they may be temporarily defeated (and that happened a lot in Jewish history) God is simply "slow to anger" not completely silent or ineffectual on the matter. 

In punishing the wicked, the righteous will be protected. To an enslaved and defeated  people, this is good news indeed. There will be an accounting when God's wrath is complete. He is not slow in keeping his promises, as some count slowness to be. Neither is he unconcerned, nor is he Powerless. 

Peter (who, it should be remembered, was a Jew) says 


  if he did not spare the ancient world when he brought the flood on its ungodly people, but protected Noah, a preacher of righteousness, and seven other ... if this is so, then the Lord knows how to rescue godly men from trials and to hold the unrighteous for the day of judgment, while continuing their punishment. (2 Peter 2:5,9)


For the Christian it holds a secondary meaning, namely that God may be love, but he is more than love. God is not just "nice," but he is also just. It is too easy to forget that because God is good, it doesn't mean he can't be powerful too.