The Hornblower books are classics. They're not perfect, but point me to something that is... C.S. Forester didn't invent historical fiction, but he may have been one of the pioneers in putting his entirely fictional character right in the middle of actual historical events in a rather-believable way. It's my understanding that part of the inspiration was reading old Naval Chronicle letters (basically a periodical that published after-action reports and correspondence about naval affairs) and imagining what sort of person was writing them. That combined with a trip to Central America (the Gulf of Fonseca, the setting of a good deal of the action in the first Hornblower book, is a real place, which set the tone-- I don't think there are any completely fictional locations in the entire series, other than an imaginary chateau here or a manor house there-- ) and some other influences, and Hornblower was born.
The character's name was supposed to evoke both heroism and the ridiculous. (The character even muses about that on occasion, coming close to breaking the 'fourth wall,' to use a theater term.) Forester intentionally made him different from himself, notably including mathematical talents and a complete lack of a musical ear because he wondered what it would be like to have those characteristics.
Forester often found Hornblower difficult to write, and even developed a bit of antipathy towards his character at times, though some story ideas he had just absolutely demanded that Hornblower be involved. I think he made his peace with Horatio toward the end of his life, and was in the middle of another Hornblower novel when he died (the completed portion and a brief synopsis of how it would have ended were published as Hornblower During the Crisis).
Forester wrote a lot of other stuff, and good stuff too-- he wrote The African Queen, which was made into the famous Humphrey Bogart-Katherine Hepburn movie, for instance-- but Hornblower remains a perennial favorite.