What is History but a fable agreed upon?
It's a rhetorical question that additionally includes the response, the opinion of the speaker.
What is History? It's only a fable agreed upon.
I think that but is used to link both sentences and to remark that the question does not admit another answer.
History is just a fable agreed upon and nothing more.
According to Oxford Dictionary
used to indicate the impossibility of anything other than what is being stated.
So, but is very meaningful in the sentence.
And last but not least, let me link this very interesting blog that studies famous quotes. It seems that "your" quote was not originally coined by Napoleon.