Well here you have a hint : if it was about stories (like tales), you would have : "Il a beaucoup de livres d'histoires", with an "s" (plural form). Because it is singular, you can hint that it is about History (in a sense of what is past). I think that should be a pretty good indication of when to use each one.
If you need anything else...
DL seem to have a problem with 'de' or d' in this case. If you click on the translations for de, you are presneted with 'of, from, to' which in many cases is irrelevant. In this case it doesn't like 'on' history, it only accepts 'about' history. You could argue the difference but you'd lose the will to live!