The version I found in French is
L'histoire est une suite de mensonges sur lesquels on est d'accord.
Translation:
History is a series of lies that people have agreed upon.
Napoleon supposedly said this after his defeat at the Battle of Waterloo in June 1815. However, I could not find any source for the above French wording in online sources (on Google Books or Archive.org, for example).
As Spagirl has already found out, the source of the quote can be found in Le Mémorial de Sainte-Hélène by Emmanuel-Auguste-Dieudonné, comte de Las Cases (1766–1842), who stayed on Sainte-Hélène until the end of 1816 (where Napoleon died in 1821).
More precisely, the quote can be found in an entry from 20 November 1816:
Il faut en convenir, me disait aujourd'hui l'Empereur, les véritables vérités, mon cher, sont bien difficiles à obtenir pour l'histoire. (…)
Cette vérité historique, tant implorée, à laquelle chacun s'empress d'en appeler, n'est trop souvent qu'un mot: elle est impossible au moment même des évènements, dans la chaleur des passions croisées; et si, plus tard, on démeure d'accord, c'est que les intéressés, les contradicteurs ne sont plus. Mais qu'est alors cette vérité historique, la pluplart du temps? Une fable convenue, ainsi qu'on l'a dit fort ingénieusement.
The last sentence can be translated rather literally as follows:
But what is then this historical truth, most of the time? An agreed upon fable, as someone said very ingeniously/cleverly.
In the preceding sentence, Napoleon had said that historical truth
is too often merely a word: it [i.e. the truth] is impossible at the time of the events, in the heat of opposing passions, and if later, people remain in agreement, this is because the concerned parties, the opponents (or contrarians) are no longer around.
So it turns out that the original Napoleon quote has a subtly different emphasis, namely the difficulty of finding truth (about historical events), rather than the concoction of lies (as in the first version above) or because history is written by the victors, which is another famous quote (though not attributed to Napoleon).
Quote Invistigator has an article about What Is History But a Fable Agreed Upon? but it gets two meanings of the French word histoire mixed up:
- story
- history
The first meaning is used in the following quote from Fontenelle's De l'origine des fables provided by Quote Investigator:
A quel dessein nous l’auroit-on donné pour faux? Quel auroit été cet amour des hommes pour des faussetés manifestes & ridicules, & pourquoi ne dureroit-il plus? Car les Fables des Grecs n’étoient pas comme nos Romans qu’on nous donne pour ce qu’ils sont, & non pas pour des Histoires; il n’y a point d’autres Histoires anciennes que les Fables.
The last sentence should be translated as
There are no other ancient stories than the fables.
Since this book is about the origin of belief in the supernatural and the role that "fables" play in this, I discard the Fontenelle quote as a source of quote "History is a set of lies agreed upon".
The second meaning of "histoire" is what we are actually looking for, and this meaning is used in the quote from De l'esprit by Claude-Adrien Helvétius, published in 1758. Quote Investigator quotes from a snippet view on Google Books, but the quote can also be found on page 449 in volume 2 of an 1822 reprint (italics from the 1822 edition):
Les motifs qui, dans ces cas, déterminaient les sultans, sont presque toujours cachées: les historiens ne rapportent que les motifs apparens; ils ignorent les véritables; et c'est à cette égard qu'on peut, d'après Fontenelle, assurer que l'histoire n'est qu'une fable convenue.
The last part of the quote can be translated as follows:
and it is in this respect that one may, after Fontenelle, assert that history is merely an agreed-upon fable.
Helvétius here refers to the Fontenelle quote discussed above, but in my view adapts it to suit his purposes by using a different meaning of "histoire" than found in his source.