The answer usually given by modern-inclined Jews has two parts. First, that Jewish traditional thought has not insisted on taking this and similar stories literally. The midrash states that the flood waters did not fall on the land of Israel. Some later commentaries say, based on this, that the flood did not cover the land of Israel - despite the flood's seeming world-wide extent in the Torah, and the questions raised by humans and animals in Israel seemingly being able to survive.
Second, that the flood story is intended to teach us ideas, not science. The ideas are powerful enough. The Babylonia flood stories (Atrahasis and Gilgamesh), for example, begins with the gods being unable to sleep because human beings are making too much noise, so they decide to wipe out humanity to eliminate the noise. The Torah's story, in contrast, features a single God, unaffected by human actions. However, when humans behave evilly, God brings the flood to to punish them. God, through his distress at having to destroy the world, shows His caring for humanity in tension with His need that the world which was created for good, actually stay good. The ideological difference between the Babylonian and Torah flood stories is vast, and the Torah's story represents many of our highest theological ideas. So, bottom line, we accept the flood story's lessons about God and morality, while feeling free to ignore its scientific difficulties.
This answer addresses many of the difficulties with the flood story. And yet it does not totally suffice. Yes, the flood story is meant to teach ideas. But does that mean it cannot also teach science? Perhaps there was no good way of teaching science in such a story, but why then teach erroneous science? Shouldn't a perfect God be able to write a text that conveys the ideas, while also not making errors in the science?
To address this, perhaps we should examine how history was transmitted in Biblical times. A key text for this is the beginning of Haazinu (Devarim 32:7):
Remember the days of old;This is the introduction to a description of how God created the world with its various peoples in the distant past, before separating out the Jewish people as His special people. I think it is not just a poetic introduction, but important evidence for how people in Biblical times would attempt to obtain knowledge about the past.
Consider the years of many generations.
Ask your father, and he will tell you;
Your elders [or grandfathers?], and they will say to you.
How would a modern person answer a question concerning the distant past? Perhaps they would perform an experiment, digging in the ground to see what is buried there, or making calculations based on some measurement. However, the scientific method was not a practical option for ancient people. They were not trained to use it, but even if they had thought to perform experiments, they could only perform a handful of experiments. They would not have access to the hundreds of years of slowly accumulated data which form the vast majority of 21st century scientific knowledge.
A modern person might also considering reading a book. This was the default option before the scientific revolution. The writings of classical and medieval thinkers provide a great deal of thoughtful analysis from some of the most brilliant people the world has seen. And yet, in the Biblical period this option too was unavailable. Not only because classical culture had not yet arisen, but because books of any sort were hard to obtain. Even in the cosmopolitan capitals of Egypt and Mesopotamia, the ability to read and write complex ideas was often limited to the priests, who jealously guarded this secret. In more rural and nomadic societies like ancient Israel, written stories and the ability to read them were surely even more rare.
Without access to knowledge from experiments or books, how would a person find out about the past? I think the best remaining source of knowledge was oral tradition. Your own parents, as well as the wisest elders in the community, would remember events from before your birth. Particularly significant events would likely be passed down as traditions over multiple generations. Of course, oral tradition tends to diverge a bit with time. But when all the elders agreed on the core of a story, you could rest assured that that story really took place.
Stories of a great flood are pervasive in many traditional cultures, worldwide. It is unclear exactly why. Perhaps they are based on memories of a sea level rise after the Ice Ages (which swamped many coastal areas - permanently), or of local floods (in low-lying places like Mesopotamia). Perhaps people saw fish fossils in the mountains, and could only explain them by positing a great flood. Whatever the initial motivations for a flood story, it morphed into a tradition held by many people who had never seen the evidence for it. For our purposes, what matters is simply that such a story existed, and likely, belief in it was near-universal. One could not simply deny that a flood took place. The elders all believed that a flood had occurred. Since oral tradition was the most reliable source of knowledge at the time, denying their story would effectively be an irrational denial of reality.
What options, then, were available to the author of a new narrative, like the Bible? If one denied the flood, people would not stop believing in a flood, but rather, the new narrative would lose credibility, just as stories of a literal worldwide flood have no credibility in modern times. If one ignored the issue of a flood, people would go on believing their preexisting flood story, with a multiplicity of deities and a debased moral order. The only option was to describe a flood, but to replace the problematic parts of the story with non-problematic parts. That way, people would only have to reject some details (and the details, unlike the big picture, were probably already in dispute), while not being asked to reject reason by denying the most reliable source of knowledge at the time.
For this reason, I think, the Torah includes a flood story similar those common in the ancient Middle East. (Even some minute details of the Torah's flood story, such as the dove and raven being sent out from the ark, appear in the Babylonian versions.) At the same time, everything that was theologically problematic was erased and replaced. This was the only way to write a text that had a chance of being accepted, while also saying all the theological things that needed to be said.
To return to our question: Shouldn't a perfect God be able to write a text that conveys the ideas, while also not making errors in the science? Perhaps, in this case, the answer is no.
(The same analysis may apply to other stories in the first 11 chapters of Breishit.)