Not too long ago, we had quite the situation at work. We got a virus into the network, which started encrypting all our files and stopped us from using them. The only way to unlock the encryption was to pay money into a BitCoin-account. Now, this is a company, where we take regular backups, re once the virus was stopped, we rolled back an hour, and everything was back to normal. But what when you are not a company? Making sure it never happens in the best defense.
The best way to prevent viruses and malicious software to enter your computer or network is to use virus software that regularly scans your computer for virus. That, together with a common sense, will prevent 99% of all viruses to be stopped from never getting in. But there are other ways to stay protected as well.