To disabuse the error of the question, in the setting of "The Count of Monte Cristo," Louis XVIII sits on the throne in what history records as "The One Hundred Days," France having been restored to a monarchy after Napoleon's beoming deposed as Emperor and exiled to Elba where he is a virtual prisoner. It is the captain of Monsieur Morrel's ship, the Pharaon, a Bonapartist who strives with others to have Napoleon restored as Emperor of France, who gives Dantes the letter.
This dying captain entrusts his letter to Monsieur Noitier to his next-in-command, first mate Edmond Dantes, whom he knows well as a loyal young man. Also, Dantes is sworn to obey his superior officer, the captain. In addition to these reasons, the captain probably understands that the young Dantes is naive. This naivete is later evidenced in Dantes's own words to the Deputy Procurer de Roi, Monsieur de Villefort:
Extreme political views, monsieru? Alas! I am almost ashamed to say it, but I have never had what one calls a view; I am barely nineteen years of age, as I have already had the honour to tell you. I know nothing, for I am not destined to play an great role in life....My opinions, I do not say political, but private, are limited to these three sentiments: I love my father, I respect Monsieur Morrel, and I adore Mercedes. That, monsieur, is all I have to tell you.
Ironically, it is this naivete of Dantes which becomes his nemesis as he innocently delivers the letter and unsuspectingly reveals that it is addressed to M. Noitier, the father of M. de Villefort, who is at political ends with his son who he is a royalist that desires the king to remain on the throne in order to further his own political aspirations.