"History is philosophy teaching by example" seems, oddly enough, to have been said by President James Garfield, whose pithy quotes are otherwise unknown to me. Of course, this one itself isn't actually pithy, since the full quote goes on to say "and also warning; its two eyes are geography and chronology." I have no idea what any of that means, so let's stick with the first part.
As a special case, straight historical fiction leases history for its productions, but SF and fantasy can use history in a way no other literary form does: by stealing it, filing off the serial numbers, and claiming ownership. Asimov took the idea for a collapsing empire from Rome and stretched it across the galaxy in the Foundation books, and it's been a staple ever since.