Is it just a cultural thing ("they've always sounded that way") or is there some basis in music theory for this?
As ZombieSheep explained, there are real technological reasons for it. The common terms for the phenomena he describes are:
Tube amplifiers also create more and / or more pleasing harmonics than do solid state ones.
There is an important caveat to this discussion, which keeps the situation from being as simple as tube=good, solid-state=bad:
The way that tubes break up (distort) is well understood and many modern solid-state amplifiers do a very good job of impersonating it in a durable, affordable package. Also, amplifiers may combine other techniques such as digital modeling or the inclusion of a tube in the pre-amp stage to provide good distortion and harmonic richness.
EDIT: In addition, I should have noted that solid state amps are capable of creating powerful clean tones that tubes have trouble with because of their tendency to distort when driven hard. The most notable example is probably the Roland Jazz Chorus Wikipedia
It's not just a cultural thing. There's actually a very simple explanation for it, although it is quite difficult to explain without images, but I'll give it a go. :)
The reason is to do with the way that a tube (thermionic valve / vacuum tube / valve) reacts to the signal in a very analogue way, and in a way that the human ear is much more adapted to deal with.
As an input signal approaches it's maximum level there are a couple of ways the electronics can cope with it.
A transistor has a very harsh cutoff of maximum signal. As the amplitude of the signal starts to rise, the highest peaks get cut off at a very specific level, and so you sound wave is effectively squared off. If you can imagine running a sine wave into a transistor amp, and cranking the levels, what you'll start to see in the output waveform is the signal tending towards a square wave. If you've ever listened to a pure square wave, you'll know it sounds very harsh and mechanical.
A valve reacts very differently, though. As the amplitude rises towards the maximum the valve can cope with, the signal is compressed more and more. As a result of the compression of the signal, the hard shoulders of the sound wave are rounded off. The harsh sound of a square wave is a result of these hard shoulders so as they are rounded off, the sound you hear starts to sound less mechanical and more natural to the human ear.
I'm sorry this description isn't particularly easy to follow, but I couldn't add images that would help to explain it.
Building on what @gomad said, "Tube amplifiers also create more and / or more pleasing harmonics than do solid state ones."
Tubes and solid-state generate harmonics when they can not output any more signal and begin to distort/clip. Harmonics are tones related to the base tone, such as a C note has a first harmonic one octave higher, a second harmonic two octaves higher, a third harmonic is a fifth above the previous one.
Tubes tend to emphasize even-order harmonics, which are octaves and fifths, and harmonize with the root note naturally. The resulting sound is not so much distorted as it is fatter, i.e., more harmonically complex. Only when you push a tube really hard does it start to get buzzy.
Solid state devices like diodes and transistors tend to generate odd-order harmonics, which sound like buzzing or raspy noise. Think back to early psychedelic rock, when guitarists were using early fuzz boxes running into clean amps. Those boxes used little solid-state amps that overdrove a device (transistor or diode) and clipped. In retrospect most of the boxes were pretty nasty sounding - heck, I thought they sounded bad back then too. (Rats, I just dated myself.) Not all solid state devices sounded bad though - Yamaha had FET transistors (Field-Effect transistors) that sounded much more tube-like. I have a Yamaha G50 combo using them, and it is still a very nice sounding amp. (I had it in the shop recently for a check-up and to get the pots cleaned, and the tech said it has an amazing clean sound that sounds just like a class-A amp.)
Roll forward many years, and our distortion boxes are a lot more sophisticated. A lot are using integrated circuits which are able to generate more even-order harmonics.
Roll forward even to more recent times, and we're seeing computers running algorithms to modify sampled guitar signals on the fly - modeling amps are solid state, but are really just computers running software that can adjust the sound as it's coming from the guitar in real time, to imitate the way the sound is modified by tubes, wooden cabinets, and different speaker types, microphones recording the speakers, etc.
Eventually they'll get modeling amps with fast-enough CPUs to run even more sophisticated algorithms, and it will become very difficult to tell whether it's tubes or solid-state. My Pod X3 can generate some very convincing tones as is. It's not responsive like a tube amp, but give them faster computers and the responsiveness will follow.
Also, part of what makes tube amps sound so good is we are conditioned to like that sound because of our culture. We like rock and roll. Early rock artists listened to blues artists, who listened to early jazz artists. All those musicians couldn't afford killer 100 watt boutique heads. They bought cheap tube amps, because that's what they could afford, often made based on tube radios or phonographs, and pushed them to their limits to be heard in noisy bars. The sound of those distorting amps got to be expected, then imitated deliberately. Now days we can't imagine rock or fusion or some low down dirty blues without some distorted, sustaining guitar in it, and it's that tube sound at the core.
Actually solid state sounds better!! A JFET has very similar response to a tube(a pentode at least). A tube is actually less perfect than a transistor. BUT THAT IS THE PROBLEM!
A tube adds much more distortion to a signal than a transistor(in most designs) BUT it generally(not always) adds a distortion that reinforces the sound. A push pull amplifier generally adds odd order harmonics. It's designed to cancel out even order allowing for more power output. For a single ended class A amp the 2nd harmonic is the strongest(the 5th).
These harmonics are much stronger in tubes than solid state but exist in both. It seems that we prefer these colorations as they make the sound more "interesting".
There are other reasons too:
But it is fact that tubes are less ideal than transistors... for some reason this makes them seem to sound better. No one knows exactly why and many tube amps suck. Also many tube amps suck on low volume(usually class B push pull because of intermodulation distortion) while a SS amp should sound almost the same at all volumes(until it starts clipping).
You can take two tube amps, same make and model, and one can sound good and the other bad. This is because the cheap components used and the tolerances can be quite wide. (standard caps have a +-20% difference and resistors from 5% to 10%) So even though they are the "same" they are not.
Some of the new digital modeling amps do quite a nice job at getting very cool distortion and excel at clean sounds(but again, sometimes it's too "clean" and too perfect).
Eventually tubes will go away... probably in the next 50 years...
Most of the other responders have touched on what I think is the main point, that tube amplifiers distort the sound in a way that can sound more 'natural' and more 'pleasing'. One thing I think they have not mentioned is that solid state amplifiers actually replicate the sound much more exactly, amplifying the sound of the instrument or whatever input device almost exactly how the sound went in. In applications such as guitar amplifiers, distortion is often sought after as a benefit, so in fact the tube amplifier is in actuality acting both as a distortion device and an amplification device. Although the tube amp creates this distortion the end result may sound more pleasing. If your goal is to amplify the sound most perfectly, solid state amps win hands down, no question. But perfectly replicating the input is not always desired. A tube amp can give a softer feel to the input sound making it easier on the ears. This is especially important with electric guitars. Standard acoustic guitars already naturally have the sound altered by how the sound reflects and resonates inside the body of the guitar, making the 'raw' sound that the vibrations of the strings create have greater depth and body. Although a tube amp doesn't effect the sound anywhere near as much as the body of an acoustic guitar does, the tube amp does give the raw vibrations of the strings a subjectively better sound.