Everything around is is matter and all matter is made of molecules. The molecules in matter can be packed at different densities. Molecules in a solid are packed together more tightly while molecules in a liquid or gas are packed together more loosely. When energy, such as the moving air that makes sound, strikes the molecules in matter, it causes the molecules to vibrate back and forth which produces a wave of sound energy. If the molecules are packed together closely, the sound can be transmitted easier. In a solid, where the molecules are packed together tight, the vibrating molecules do not have to move very far and hence, the sound travels faster. Solids are excellent transmitters of sound. Steel can transmit sound at 5,200 meters per second vs. 340 meters per second when traveling through the air. This explains why putting your ear to a railroad track, although very dangerous and stupid, lets you hear the train much further away than simply listening for the train sound coming through the air.
By the way, sound travels faster through hotter objects too.