Malware uses interesting techniques for hiding themselves from anti-malware software and more. They can "polymorph" themselves: practically change the code while it continuing to mean pretty much the same to the executing machine, making antivirus definitions invalid etc.
I wonder if there is anything (non-malicious) developers could learn from studying the source of such, or reversing them and studying whatever you get from that process if the source isn't available, that could be useful outside this (dark?) realm.
I am not interested in writing malware. (at least not for non-educational purposes) This question isn't meant to be a question about how to write malware or such, but what you could learn from already written malware.
Also, maybe a bit unethical (I hope not), would there be any gains from writing your own piece of malware, just for better understanding of vulnerabilities/exploits/security, or the underlying operating system?