I suppose you'll get conflicting answers depending who you ask, but here's my take on the difference between history and historical fiction:
History deals with what's probable, historical fiction works with what's possible.
There's a big difference between these two!
A book of history is based on what we know for sure happened, and for the many gaps, experts do their best to paint in what most probably happened. You're going to get conflicts of opinion because the experts weight the available evidence differently, and personal interpretation comes into it, but no matter what, everyone's arguing for their own view of reality.
Historical fiction is about what's possible, not what's most probable. The historical fiction writer selects the interesting or dramatic within the wide range of possibilities that might have happened, unlikely as some of the options are.
For example I have Pericles commissioning Nico to find the killer of Ephialtes. There was a for-real Ephialtes, and he was for-real murdered, but there is not the slightest evidence to suggest Pericles commissioned an investigation. On the other hand is there anything to prove he didn't? No. Good, so this plot is fair game for an historical mystery writer.
This can become a grand game of what-is-the-most-outrageous-thing-you-can't-prove-didn't-happen. For example I mentioned the other day the possibility of killing someone beneath the hooves of stampeding mules at the Olympics. I could kill someone that way, in theory, because no Classical Greek ever actually wrote, "I went to the Olympics last week and funnily enough no one died beneath the hooves of stampeding mules." But I won't because there's a limit to the credibility I can stretch you, and that might be a trifle over the top, even for me.
The key element is it's a game. In fact, it's a game within a game, because if you're writing historical mystery then there's a murder for you the reader to solve, there's real history to deliver, there's warped possible history to interlace with the real history, which is fun for me, and there's the game the reader gets to play spotting the places I got it wrong.
I do have to get it wrong in places. I estimate the number of details in each book is in the low hundreds; it's impossible I could get them all right. The most accurate historical fiction writer ever was probably George MacDonald Fraser with his Flashman stories, and he famously placed the Duke of Wellington's wife at the opera three years after her death. If he can't get perfection, I certainly can't, but I try.
I do think it necessary the historical fiction writer not break known history. So for example if I wrote a story in which the Athenians conquered Rome, that would be naughty. Something like that isn't historical fiction, it's alternate history, which is a quite different genre closer to fantasy. But where there's uncertainty, and I'm allowed to pick and choose from the possibilities, no matter how unlikely they might be, you can be reasonably sure I'm going to pick whatever's funniest.