In day school my teachers often said that the torah isn't a history book. Today academicians, historians, and the like diligently present historical inaccuracies in the bible. For example the story of creation; it is not factually accurate to say that the world was created in 6 distinct 24 hour days. To my knowledge nearly every Jewish commentary does not read this story literally.
The general response to historical inaccuracies I have heard is that the torah is not interested in presenting history, it is a book which teaches us how to lead a moral life by serving God. So if, for example, the flood didn't literally cover the whole world, that is less important then the lessons conveyed.
My question is, given that God is omnipotent, why wasn't the torah written in a way that served both purposes? Is there a purpose in intentionally writing the bible in a non-historically accurate way? In other words since it is conceivably possible to write both a historically accurate book which also teaches us how to lead a moral life by serving God why wasn't the torah written that way?