Fermat's last theorem is a great example - it is in itself a completely irrelevant observation, not used (so far) in any larger theory. It was only pursued because (a) Fermat casually claimed to have easily proved it (almost certainly being mistaken about it), and (b) it sparked the curiosity of mathematicians because it looks so simple but turned out to be so hard.
So what does humanity gain by knowing that the theorem holds? Basically nothing. What does humanity gain from the process of proving it? As far as it is known for now, basically nothing (though it is somewhat likely that the complex theories created to prove it will find other applications). However, those that have worked on it, and the guy who did prove it, gained a huge amount of personal insight into mathematics, and surely grew as mathematicians, and will hopefully use those skills in working on other problems that may prove more directly useful. Plus, they had a great time doing it.
What this means is that, if the proof had been discovered entirely by AI, basically nothing would have been gained. LLMs don't learn by doing, so no personal experience growth would have come from this; and as I mentioned, both the result and the proof are, so far, quite irrelevant even for mathematics more broadly. So it would have been actively detrimental, or at best neutral, compared to letting human mathematicians work on this problem, in a way that is never the case in science or engineering, where any bit of knowledge is in itself useful to at least some extent.
Also, that Sudoku analogy doesn't sound right to me. Math progress is more complex than that.