A big factor that contributes to the existence of viruses, spam, and the like is their lucrativeness. Unlike the drug trade, legalization would not make much of the problem go away, but the issue is similar, because economics plays a much bigger role than is generally acknowledged.