I'm personally fascinated by history, but it's difficult for me to use this passionate love affair in my writing because I'm interested in real history and real historical figures. And if you write about real people in your books, even those who are long dead, you may experience backlash in all sorts of different forms. But other authors have learned how to beat the system, and they've done it so well there's an entire literary technique named for this sort of savvy trickery. It's called roman a clef, and you don't even have to be French to use it to avoid lawsuits and other author troubles.
At Their Own Game
Want to write about something real, but fear reprisal? Don't shrink from the story you want to tell. Pull a fast one on them, and use roman a clef.
This French term is used to describe a novel that is about real life -- real events and real people. This type of novel, however, is very thinly disguised as fiction. The trick is that the names are changed, and a key is added to the back of the book showing which "characters" represent which real people.
It's just that easy to beat the system. And it's been done time and time again by countless authors for all sorts of reasons.
The roman a clef technique can be used to write about controversial subjects, such as politics, without putting the author at risk of lawsuits. Some authors use this technique in order to remove themselves from the story; they don't want to go public with the fact that the main character is actually themselves.
This technique has been in used since at least 1466, and it's still being used today because it works. Some examples of this technique include The Sun Also Rises, by Ernest Hemingway. The book is about Hemingway's own exploits in Paris and Spain, where he rubbed elbows with many famous names of the day. George Orwell's Animal Farm contains several characters who were figures in the Soviet Union. Sylvia Plath's depressing The Bell Jar is about herself. The Devil Wears Prada is possibly about Vogue editor-in-chief Anna Wintour (Meryl Streep's characrer in the film), but the author denies it.
No technique is foolproof, of course, and no author is fully safe when writing about real people. So always use caution, and remember it may be much wiser to continue calling your book fiction and refusing to name any real names. You don't have to stop writing that story, or avoid using the characters you want. Just change the names, hide the truth a little, and play it safe.