fondue's indictment of Fermat seems unduly harsh to me. Bear in mind that Fermat scribbled this note in his personal copy of Diophantus' Arithmetica. As such, it was likely just an idle musing that was never intended for general consumption. In fact, Fermat himself never published or promulgated the theorem, although he did issue the special cases n=3 and n=4 as challenges to his colleagues. The marginal note was found and published by Fermat's son Samuel.

Based on these observations it seems likely that Fermat found one of the bogus proofs, jotted down a note to himself, and later realized the proof was in error. He then simply forgot about the matter, since he never expected anybody else to see his note, which seems eminently reasonable to me.

However, it's kind of amusing to reflect one of the greatest enigmas in the history of mathematics came about entirely by accident. Had Fermat's private comment not leaked out the theorem might have remained undiscovered until it fell out as a consequence of studies in elliptic curves, and it almost certainly would have remained an obscure footnote to number theory and not have captured the public imagination the way Fermat's Last Theorem has.