All computer systems can be infected. As popular as Apple products are, Microsoft Windows still takes the cake as the more commonly used system. Therefore, cybercriminals want to create viruses and malware that will target and infect the larger population – Windows users. That aside, OS X is also considered to be one of the safest operating systems (thanks to its UNIX foundation), making it less likely to welcome an online threat.
This definitely doesn’t mean that your Mac is safe from an attack, however. As popularity of the system increases and more programs and applications are added, it does become more prone to a vulnerability. So, you should still look into antivirus software.