Why did classical-era composers associate keys with moods?
Composers of the classical era, especially Mozart and Beethoven, considered certain keys appropriate for certain moods. What reasons did they have for this?
There are practical reasons for choosing certain keys. Making the best use of an instrument's range may require a certain key. Violin concertos favor sharp keys so that the player can use the open strings more. On the piano, some keys lie under the fingers more easily than others, and C isn't always the easiest.
But I'm talking about the mood which a key is supposed to represent. Beethoven used E-flat for the Eroica Symphony and F for the Pastoral Symphony and the Eighth, and there's no chance he'd have done it the other way around. Mozart and Beethoven both used C minor for serious, heavy works. Mozart treated G minor as a key appropriate to great sadness.
Mozart may have had absolute pitch, which might explain why the choice of key was so significant to him. I've never heard that Beethoven did.
Perhaps the idea was a carryover from the days when unequal tuning was normal. Each key definitely had its own flavor under the older tunings.
Brass instruments are often transposing instruments in flat keys, less often in sharp keys. This might help explain why E-flat is a "heroic" key, since such works benefit from the brass section.
These are guesses. Can anyone offer a more comprehensive or documented explanation of why certain keys meant certain things to those composers?