Why did the God of the Old Testament kill every living being? He may have had reasons to kill some bad humans, but why kill innocent animals?
Because the story of Noah was an adaptation of the story of Utnapishtim in the Epic of Gilgamesh (tablet XI specifically) which simply substituted the Hebrew god into the narrative.
Gilgamesh isn’t original either. It was adapted from an earlier Akkadian epic Atrahasis, which was itself adapted from the Sumerian epic Ziusudra.
Consider how people of that time understood the world they lived in. A local flood would have been their entire world.
A few generations of “telephone” later, with all the embellishment that comes with it, being taught to each successive generation as fact, and you have the fantastical story we all know today.