Because the letter Dantès carried from Napoleon was addressed to Villefort's father, Noirtier. Villefort can use the information in the letter to advance his own career, but only if nobody knows to whom it was written. If Noirtier was identified as the intended recipient, then Villefort would always be under suspicion as the son of a known Bonapartist. This would doom his prospects. Besides, Noirtier would surely be put to death if his involvement with the conspiracy came to light; and despite their political differences, Villefort does not want his father executed.
Dantès naïvely admits that he alone knows for whom the letter was intended. Villefort realizes that all he needs to do is destroy the letter. He could still use his knowledge of the letter's contents to thwart the plot, thus gaining ascendancy at the court; but with the letter burnt, nobody need know that Noirtier was involved in the failed conspiracy. The only snag is Dantès.
Dantès has no idea that Noirtier is Villefort's father. Villefort needs to ensure that Dantès will never reveal what he knows (that the letter was to Noirtier), nor learn what he does not know (that Villefort is Noirtier's son). Villefort cannot condemn Dantès to death, because that would involve a trial or at least a sacramental confession, where Dantès might let slip that the letter was addressed to Noirtier. So Villefort's only hope is to put away Dantès as quickly and completely as he can.
Hence the necessity, in Villefort's eyes, of having Dantès locked away for ever. Dantès is too dangerous, because he knows what Villefort needs to conceal at all costs.