Antivirus software is used in computers to protect them from malicious software such as viruses, worms, trojans, spyware, and ransomware. These harmful programs can infect a computer and cause damage by stealing personal information, corrupting files, or slowing down the system. Antivirus software scans and detects these threats, preventing them from causing harm and ensuring the security of the computer and its data.