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:
A tube (valve for you Brits) approaching or exceeding its maximum signal level creates distortion, a highly sought after effect in some circles.
A solid state or digital circuit approaching or exceeding its maximum signal level creates clipping, a horrible sound that most people hate.
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.
I think if compressors where invented earlier and loud amps were very affordable back then, distortion wouldn't have become such a sought after sound.
http://www.bluesharp.ca/legends/lwalter.html specifically says this about Little Walter, probably the most influential blues-harp player ever:
Little Walter is considered by many the king of blues harmonica and was probably the first to amplify the instrument. He was the first musician of any kind to purposely use electronic distortion (later Jimi Hendrix would use distortion to change rock'n'roll forever). Little Walter could make his harp sound like a tenor sax. He defined the sound known as Chicago blues harp. As a singer, composer and harmonica genius, Little Walter was arguably the best blues artist produced by the post war Chicago blues movement.
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:
Tubes are generally used with a supply of several hundred volts. This gives a much lower noise floor and hence more headroom. Although this truthfully isn't a huge deal in a properly designed amp.
Tubes are much less perfect in design giving many different types of responses for different tubes and even the same tube design.
Tube theory has been very well researched and really is what we base our SS theory off of(no coincidence since the physics are abstractly the same). Many many many man hours have been put in getting the best out of tubes. SS is so close to ideal even a poor design can work well.
Tubes have a more gradual clipping action when they are overdriven. This actually makes them have less distortion than a SS amp when it is overdriven.
Tubes were here first and hence have the psychological factor.
Because of all the different variables in a tube(from the resistor's and capacitors used to the different types of stages) it has a much wider range of sounds that all might seem subtle but can have a big effect on feel.
Feel - tubes have a certain response that "feels right" when playing guitar. Maybe it's psychological maybe not...
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...
This is phenomenon of perception that is confined to guitar amplifiers, and those arguments against solid state amps are at least 45 years out of date. If you've been surfing the Internet, you're going to be inundated with information.
In the arena of hi-fi amplification, solid-state wins--no contest. Total harmonic distortion is the almighty parameter, because a low THD value means that the signal that comes out is almost exactly the same shape as the one that goes in. (And the best hi-fi amp ideally adds NO harmonics, even- or odd-order.) Plus solid-state handles heat better, is more durable, cheaper, smaller and more efficient. That's why all serious PA equipment is solid-state.
To understand why tube guitar amps sound pleasing you first have to know that Marshall designed the first high-gain preamp circuits to emulate the sound of malfunctioning tube amps as they "broke up" the signal after hitting the maximum voltage available. Regardless of the handful of differing views on the matter, tube distortion is THE sound of rock music by an overwhelming consensus of opinion. Believe it or not guitar amps are purposely designed to sound "bad" with respect to high-fidelity parameters.
The soft-clipping and voltage peculiarities of tube amplification have been nailed by solid-state designers for over 30 years. There's really no reason to choose one over the other, so long as it's quality equipment. (Doubters were discredited a couple of decades ago in blind tests where they failed to tell the difference--so it's all opinion at this point.) Yet some of the worst-sounding amps available are solid-state because they're so cheap to make. (Oddly, people who won't buy one $500 amp will buy six $100 ones.) Poor quality amps have not helped the solid-state circuit's reputation. However, with the present tube amp craze there's no shortage of low-quality amps in that category as well. Tube amps are great for makers in this economy because they provide them with a Kodak business model, since tubes must be replaced eventually.
Truth #1: Tube amps aren't louder than solid state. Fifty watts is 50 watts and 100 watts is 100 watts--the efficiency of your speakers make the difference. (A 103 dB 1w/m loudspeaker is perceived as twice as loud as a 93 dB 1w/m loudspeaker, for example.) I've stood in front of the mighty Marshall stack and I can tell you that my solid state combos--with no extension cabs--can easily play over a drum set in a club without reaching halfway on the chicken-head.
Truth #2: Solid-state is not newbie-friendly. Many players are unable to correctly set their own amp, and solid-state requires special understanding and precise movements of the dials. Tube amps are forgiving: anyone can put the dials at ten and still get only a moderately awful sound. Do that on solid-state and people are covering their ears and running for the exit! Most people find hard clipping intolerably abrasive.
Truth #3: Solid-state sounds just as flabby at low volumes as tube. If you want to play at lower volumes, get a low-wattage amp. Solid-state sounds best at about 80% of maximum gain...where it's most efficient and not likely to break up when it's working hard. (If you think this is conjecture, demo low-gain and high-gain settings on an assortment of amps at your local music mall.)
Truth #4: Solid-state amps are not newbie-friendly because manufacturers attempt to mislead buyers with specifications. For example: a famous brand that starts with 'C' doesn't even list THD ratings in conjunction with power ratings. Not acceptable! A famous 'P' brand is honest and gives the rated maximum wattage at 5% THD. However, 5% total harmonic distortion with hard clipping is grating to most people and isn't acceptable in performance. So the real usable output is about 20% less to get the THD at or below 1%. That means a rated 100-watt amp is really usable to perhaps 80-watts. Noticeable distortion in the power amp stage of a tube amp is tolerable, but distortion and hard clipping in a solid-state is unbearable to most people.
edited: More objectivity; less profanity.
One thing that might be worth noting that people talk about the characteristics of pentodes and stuff. But in a typical tube amp, one important element with its own saturation and consequently distortion characteristics is the output transformer since tubes operate at voltages and currents unsuitable for most loudspeakers, requiring a transformer for operation.
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.
Just for info: a few years back an electronics specialist friend took my 'classic' valve guitar amp into the lab and ran a few tests. Now this person had been educated to believe that solid state was king. He came back a bit surprised and reported that it had frequency response (flat) matching solid state hi-fi amps and he could not detect distortion until running 20 - 25% of the manufacturer's nameplate rating.