nobody really thinks such a proof exists, but that wasn’t as well known at the time the episode was written
that's incorrect. there were attempts at a proof by lame and kummer around the half of 19th century and no later than that people were aware that mentioned fermat's notice was probably bullshit - he either made a mistake, or had proof for some narrow case which he wrongly assumed was general proof.
it was clear at that point that there is no proof that would be discoverable by someone without proper mathematical education just because he "had an idea".
you can of course argue that doesn't mean picard couldn't attempt that, but it is quite a stretch. reality is, that some writer read about it somewhere and incorporated it into the script without thinking about it twice and as a result gave us this joke, because - well - predicting future is hard.