I live in Spain, where authors such as Ken Follet (for his Pillars of the Earth books), Christian Jacq and Massimo Manfredi and Arturo Pérez Reverte are highly regarded, and Galdos' Episodios Nacionales are part of the canon. According to hispanicist Henry Kamen this reliance on fictionalised history tends to 'distort and even intentionally falsify the past'.
Personally I read and have read and enjoyed historical fiction, including Patrick O'Brian, Hilary Mantel, Neal Stephenson, and I feel like I have learnt things about places, people and periods I might otherwise never have given much thought to.
Is there a case for historical fiction, beyond merely awakening interest in the events of the past? Are there writers who any actual historian would recommend as vehicles for genuine learning? Or are they just to be read as entertainment, providing more information about the time in which they were written than the period they are ostensibly about?
Well, the problem with historical fiction is that the degree of fictionalization is much greater than in a non-fictional (academic) work. This is obviously inevitable in order to fill in the gaps within a continuous narrative that historical sources cannot fill. For that reason, even the most meticulously researched novel will introduce a larger amount of distortion than other (non-fictional or academic) forms of historical writing would introduce into the source material.
Now, there are some writers of historical fiction out there who take the adherence to historical fact (and the amount of research they provide) very seriously, others are more liberal. But the main issue is that the reader cannot see where a narrative’s basis in fact ends and the imagination of the writer begins, since the form he writes in doesn’t require to clearly separate both elements.
For example, to mention some authors relevant to my own discipline (History of Japan), the late Shiba Ryōtarō did employ a somewhat peculiar style of switching between narrative layers between a rather dry prose depicting historical events in a more “objective,” documentary style and a zoomed-in, much more “fictional” depiction of scenes within the larger flow of things where his protagonists would then make their appearance. By this incorporation of narrative techniques normally associated with both non-fictional and fictional writing, he at least implied a clear division between the factual and the fictional components of his stories to the reader, although a case-by-case analysis would be necessary to establish how well these two narrative layers actually separate historical fact from fiction in practice.
On the other hand, Nagai Michiko, another Japanese novelist, researches her stories a lot through primary sources herself, instead of merely on history books—so much actually that, amusingly, a Japanese history professor once recommended me one of her novels as the “best-researched” (and incidentally most fun to read) work over the biographies available on the same subject in scholarly literature!
To conclude, the whole objective of history as a scholarly discipline and of historical fiction is very different; therefore, historical fiction might teach you facts (if it makes clear enough what the facts are), but it doesn't go "beyond."
As such, it obviously cannot replace history in the sense of the discipline, but it can, in theory, be incredibly accurate concerning the known historical facts that are woven into the narrative. This, however, is both a question of how much research the author has put into the subject he writes on to begin with, and how closely he chooses to adhere to the fruits of his research. However, since historical fiction typically does not clearly distinguish between fact and fiction, and doesn’t cite its sources, it cannot replace the former as a means of learning (especially not on an academic level). I therefore think it can be a fun pastime that works best if you juxtapose it with non-fiction to set the facts straight.