Why do string instruments need hollow bodies?
Yes, the room has a lot of air, but most of it isn't in direct contact with the vibrating string. In order for the string to make much sound, it needs to transfer some of its energy to the surrounding air, but there are a couple of issues which make that difficult.
Firstly, the string has a relatively small surface area, so it simply doesn't directly contact very much air.
Secondly, the string isn't very effective at transmitting its vibrations to the surrounding air. It's a bit like if you get a thin rod and wave it back and forth in water. Yes, it makes a few ripples, but the rod mostly just cuts through the water. But if you get a wide paddle and wave it around, then it's easy to make large waves in the water. Similarly, a vibrating string mostly just cuts through the air, rather than making useful pressure waves in it.
With air, it's even harder to effectively induce waves than in water, because it's so compressible. Obviously, pressure waves do travel through the air, but it's a lot harder to transmit such waves through a gas than through a denser, stiffer medium.
So stringed instruments generally have some kind of soundboard: a surface with a relatively large area that's in contact with a lot of air. The string can efficiently transmit its vibrations to the soundboard, and the soundboard can, in turn, transmit those vibrations to the air.
On a guitar, the soundboard is the front of the body. Here's a diagram, courtesy of Wikipedia:
The soundboard of a piano is inside the body:
An important concept here is acoustic impedance.
Acoustic impedance and specific acoustic impedance are measures of the opposition that a system presents to the acoustic flow resulting from an acoustic pressure applied to the system. [...] There is a close analogy with electrical impedance, which measures the opposition that a system presents to the electrical flow resulting from an electrical voltage applied to the system.
Unfortunately, that Wikipedia article is heavily technical and mathematical, without much physical detail.
The soundboard of a musical instrument, or the membrane of a loudspeaker, doesn't need to have a lot of back and forth movement. It just needs to vibrate relatively gently. Large movement wastes energy by causing bulk movement of the air, rather than inducing the desired pressure waves.
The string itself does not move the air much, does not produce much sound - hear an electric guitar without the amplifier!
In a violin it is the bridge that couples the movement of the string to the sound board which sets the air in motion.
The hollow body acts like a Helmholtz resonator.
The soundboard is the crucial component in acoustical amplification of string vibrations. The strings pass over the bridge, which is solidly attached to some part of the soundboard. A vibration at the bridge sets a good part of the soundboard in motion. This in turn vibrates the air close to the soundboard, and launches sound waves into the air, which we can hear. An important point here is that the "amplification" of the string vibration does not actually add any power that was not already present in the vibrating string. All we have done is transform the vibration from a small, stiff source (the string and bridge) to drive a large, soft destination (the soundboard then the air). This is a bit like using a lever to increase the effect of a force, without actually adding any power.
This soundboard effect is exploited in loudspeakers, where the soundboard is the large, lightweight cone, and the motive force comes from an electric current in a coil, in a magnetic field. The "motor" part of the loudspeaker, the coil in the magnetic field, would flap about ineffectually when driven by an electric signal, were the motor not attached to a relatively large cone, which actually drives the surrounding air.
Most string instruments have an enclosed sound box, the soundboard being one side of this box. This is partly practical in providing a stiff construction for attachment the strings to a neck, bridge, and soundboard. Bear in mind that the strings are under considerable tension, which would pull apart a weak construction.
This box behind the soundboard has acoustical effects as well. One problem with using a vibrating soundboard is that each side of the soundboard vibrates in opposite phase. This would mean that, at some distance away, the air vibrations tend to cancel out. This cancellation is not total. In particular, sound from the far side of the soundboard must "go round a corner", to get to the front and mix with the sound from the front. Low frequencies readily spread around obstructions, whereas high frequencies tend to be deflected. This depends on the size of the obstruction, relative to the wavelength of the sound. One effect putting a closed box behind the soundboard is to obstruct sound from the rear of the soundboard, and prevent cancellation of sound from the front, particularly at low frequencies. This effect is also exploited in almost all low frequency loudspeakers, in order to improve the bass response. Some loudspeakers, such as electrostatic types, rely on having a large soundboard area, but this is not common.
Now we come to the matter of resonance. There is some unfortunate conflict between common usage, and physics or engineering terminology. Informally, an object is "resonant" if it readily makes a sound when set in motion. A thin board of wood or a metal saucepan are resonant in this sense, whereas a bucket of sand or a woolly jumper are not resonant, in the informal sense. But to an engineer, a resonance means a tendency for a system to respond more strongly to vibrations in some narrow range of frequencies, around the resonant frequency. Organ pipes and stretched strings are resonant in this stricter sense. Real acoustic/mechanical systems tend to have many resonant frequencies.
The problem with resonances in string instruments is that we want the soundboard to be readily set in motion to make a sound (informal resonance), but we want this to happen more or less equally for all frequencies that the strings can produce. The latter requirement means that we want to avoid prominent resonant frequencies, that would amplify some notes at the expense of others. In the end, we end up with a system that does have specific resonances, but they are artistically controlled to "sound right", and make the instrument respond to the player. If we try to control unwanted resonances too much, this detracts from the desirable responsiveness of the soundboard amplification.
As a final note on resonances, there is the matter of soundholes. Specific low frequency resonances of the soundboard and the air in the box can be exploited to boost the lower frequency amplification. This gives an instrument a fuller and deeper sound. In loudspeaker technology, this effect is used to produce a bass-reflex cabinet, which has an improved bass response compared to a plain closed box.
Not all string instruments have a sound box to improve the bass sound. The piano has a very large soundboard, which helps to prevent cancellation of bass frequencies. The banjo uses a drum skin as a soundboard, with thin shell rather than an enclosing box. The banjo sound is notably lacking in bass.