Can a virus damage computer hardware?
As a computer virus is only code, it cannot physically damage computer hardware. However, it can create scenarios where hardware or equipment controlled by computers is damaged. For example, a virus may instruct your computer to turn off the cooling fans, causing your computer to overheat and damage its hardware.
The vast majority of computer viruses are designed to only target computer data. Furthermore, modern hardware is more difficult to damage hardware beyond repair. If you have problems with a computer hardware device, such as a printer, video card, sound card, or another hardware device, it's likely not due to a virus.
Corrupt drivers
Although a virus may not be attacking hardware, the software drivers that allow hardware devices to communicate with the computer may be attacked or become corrupt. If this occurs, it might prevent the device from working, but it does not physically damage the hardware. Realize though that it's far more likely that the drivers themselves have problems, or other software corrupted the drivers and not a virus. To fix this type of problem, reinstall the hardware drivers.
Corrupt BIOS
One of the most notable viruses that attacked hardware was the Chernobyl virus. The Chernobyl virus was first detected in 1999 and corrupted data on the hard drive and sometimes the motherboard BIOS (Basic Input/Output System). When a computer BIOS becomes corrupt, it causes the computer not to boot. However, this virus doesn't physically damage the BIOS; it's only corrupting the BIOS code, and if the BIOS chip were replaced, the computer would boot again. Today's computers also use an EEPROM (Electrically Erasable Programmable Read-Only Memory) that allows the BIOS and firmware to be re-flashed without needing to replace the chip. So, if a virus were to infect a modern BIOS, it could be re-flashed with an updated BIOS.
What about Stuxnet?
Sophisticated viruses like Stuxnet are designed to damage hardware that's being controlled by computers. For example, Stuxnet was designed to target the centrifuges at Iran's enrichment facilities. No computer hardware was damaged; however, the virus damaged the centrifuges because it disabled all of the system alerts that would have alerted something was wrong.
This type of virus was capable of damaging hardware because the safety measures were disabled. However, this was one of the most sophisticated viruses ever written and was targeting a specific device. If your computer got infected by Stuxnet, it would have done nothing to your computer.
What about a PDoS?
A PDoS (permanent denial-of-service) attack is not a virus, but a type of attack where a person exploits network equipment firmware by flashing it with malicious code. These attacks can damage hardware if the firmware is programmed to do something malicious (e.g., disable temperature monitors) or cause devices not to work because the firmware is corrupt.
Why a virus writer may not want to attack hardware
Someone who creates a virus is most likely creating the virus for monetary means, to spy, or to take control over the computer. Attempting to write a virus that damages hardware doesn't help accomplish any of these goals and also doesn't help spread the virus to other computers.
It's plausible that someone could write malware designed to target a person or company to damage hardware. However, for this type of attack, the person wouldn't create a virus that infects other computers.
Also, modern hardware is more difficult to damage hardware beyond repair. Today, systems use firmware that can be re-flashed or reset without replacing any chip or other hardware. Also, modern systems have safety measures that help protect hardware from becoming damaged. For example, if a system gets too hot, it can turn itself off to prevent damage.
Can a virus cause a computer to explode or burst into flames?
No. There are many stories floating around that a virus can cause a computer to explode or catch fire; they are not valid. Malicious code could damage or cause computer controlled equipment to explode (e.g., Stuxnet destroying the centrifuges). However, it would only be possible if the controlling software could make hardware do something dangerous and disable any warning or prevention systems.
Software can damage computer hardware
It's worth mentioning that software designed to adjust system settings, like the system clock settings, fans, or active heat sinks, can cause system problems with the computer. Also, in some situations, improperly adjusting these settings may even damage the hardware. However, these program settings are not computer viruses, and as mentioned earlier, modern systems are also designed to help protect hardware if it reaches a critical point.