First, I would turn the question around: why would music from the classical era use such keys?
That's IMO still a question to ask oneself: why use a key like A♭ major, when putting it in G major or A major would give almost the same registers?
Of course, nowadays with guitars and (MIDI-) keyboards being the most common instruments, musicians tend to think of all the 12-edo keys as being more or less equivalent, but this was very much not the case historically. The first music that shares our western note names didn't have sharps-and-flats at all. The first accidental that got used was the “round b” that begot the ♭ symbol, and it was only applied to the note B, i.e. B vs B♭ (called H vs B in many languages). The distinction being essentially in where the tritone appears. It was not a matter of just filling in the gap between A and B.
As time went on, more accidentals were added, but they were still constructed via diatonic scales, not from a “the octave is divided in 12 steps” perspective. And they actually had significant tuning problems, until the first well-tempered tunings arrived. Whereupon, sure enough, Bach made it a personal endeavour to write music for all those weird keys that had become available, but it was at that point more an academic exercise than a practical thing for musical performance.
For Mozart and Haydn, keys with more than 3 sharps/flats would have still been fairly exotic curiosities. Many of the instruments of the era would have had a hard time playing them, and even for the instruments that are in principle capable of it quite well, the players would have struggled. In fact, even today keys with many sharps or flats put some extra mental and/or physical burden on players. Nevertheless, neither of them were afraid to put in a liberal dose of accidentals to achieve exciting modulations.
As to why Beethoven used those keys more often? Well, he was generally a progressive mind, always eager to explore new paths, even if they were rough. If he saw some value in doing something differently, he was more likely to actually do it than Haydn and Mozart were.