The more familiar your audience is with an historical era, and the more well-documented the era, the more accurate you need to be. It is a question of audience credulity; if you stray too far you pull the audience out of the story, and that's what you want your audience to fe focused upon - the story and the characters.
That's not to say you cannot take liberties. For example, The Adventures of Robin Hood (1938) is wildly inaccurate in many ways, but it's a romantic, action/adventure, fantasy film based upon a mythical figure, so the inaccuracies are overlooked. However, you could not take those kinds of liberties with, say, the D-Day invasion. The Captain Miller character is an amalgam of several people, as is the mission he and his squad undertake, but everything else is very close to "what really happened."
As with everything else in the entertainment industry it's a balancing act.