Linux is secure but it is not perfect.
The Linux malware exists and there is an example : WordPress-Delivered Ransomware and Hacked Linux Distributions witch describe how can a linux machine will be infected with a ransomware by exploiting a program vulnerability.
How it work?
A WordPress site is hacked through any method available. That may be a brute force password guessing attack or by exploiting a vulnerability in a plugin, theme or core.
The attacker installs code on the WordPress site that redirects visitors to other infected websites that are running the Nuclear Exploit Kit. The redirects may happen through a series of websites to try and prevent web browsers and Google from warning you that a site is infected. The sites involved in the redirect change frequently.
When a visitor to the infected site is redirected, the nuclear exploit kit searches for vulnerabilities in the site visitor’s Flash Plugin, Microsoft Silverlight, Adobe Reader or Internet Explorer.
If Nuclear finds a vulnerability, it exploits the visitor machine and installs the TeslaCrypt Ransomware.
The ransomware then encrypts all files on the workstation and extorts the owner into paying to get their system decrypted.
A second example:The Linux.Encoder.1 descovred by Dr.Web
Why you don't need an antivirus program under linux?
because you installed your programs from a trusted repositories and your system is frequently updated to patch the programs flaws
with the open sources softwares, the sources codes is available for everyone and can be tested, patched by experts and developers.
Why you need an antivirus?
The antivirus can be useful:
To scan email for viruses.
If you have
wine installed on your system to run your favorites
If you have a windows machine on your network.
To scan a windows hard drive.
To scan some file before send it to windows machines.
The easy way to defeat ransomware on any operating system is having a regularly updated backup.