Thunderstorms and tornadoes are related because tornadoes always form out of thunderstorms. Specifically, tornadoes develop when there's a steady upward flow of warm air, which is generally lower in pressure than cool air.
According to HowStuffWorks, clouds are formed when water vapor cools and condenses. When water vapor cools it loses its heat energy at a rate of 600 calories of heat per gram of water that condenses. This heat helps to warm the updraft that the cloud rides on and gives the cloud kinetic energy as it moves. Considering the size of the average thundercloud, it's unsurprising that a thunderstorm can release as much energy as a 20 kiloton nuclear warhead.
There are certain thunderstorms that are classified as supercell thunderstorms, where updrafts are particularly strong. In these storms a vortex of air can be formed, and this vortex is the basis of a tornado.
Before a tornado occurs, however, clouds form something known as a mesocyclone. Once a mesocyclone forms there is about a 50 percent chance of a tornado occurring.
It's interesting to note that since a tornado is born out of a thunderstorm, the thundercloud that it came from controls the direction that the tornado travels.