Real life history can be a real bear. Or perhaps, a strait jacket would a better analogy.
Hmm, or trellis? (Writers can get silly on metaphors.) The events of the story must grow about the fixed structure of historical events, which were not themselves in any genre. William Wallace fighting King Edward ends with Wallace executed after a crushing Scottish defeat. No matter how dashing Robin Hood is, Richard the Lion-Hearted will die and leave John on the throne. (Assuming, of course, you use Richard and John in your story.) Any romance between Louis XIV and any woman is doomed, even if you tie it off nicely in the story.
Some expurgation of events and reordering things can work, but does make the knowledgeable reader notice.
Some writers get it so ineptly that it's more clumsy than fictional history. Most manage well enough, but there can be points where you see the strain. Some pull it off elegantly. I once read a work where the hero stalked King John to kill him. Impossible, of course. But King John's actual death, collapsing when his treasure was lost when the tide came in, and dying the next day, worked wonderfully well to curb the hero's arrogant certainty. But beside the elegant working in of his change with the events -- and the careful character development -- it needed the right events. History is seldom so obliging.