Because it is kind of romantic to cause destruction and watch it unfold? I'm not sure.
But just remember this - before you insult virus authors, remember that they are doing you a huge favor. They have forced companies and the government to ramp up the security of computing, and engineer security into their infrastructure (which they would not have done otherwise). Now consider if no viruses had ever been written. We would be completely vulnerable to a terrorist attack in this fashion.
Don't complain about the people who are making it possible for you to sit in front of your computer like you are doing right now, and feel safe from anything other than a minor annoyance.they are bored and have no life ,they might have been bulied in school and since they cant get u in person they eff uP your OS and now lets see whos laughing.I guess the first question that has to be answered is: What is a virus? A virus is code that is executed that does something undesireable on a computer system. So a program whose sole purpose is to delete every file in "My Documents" could be considered a virus depending on the user. Most viruses, however, try to spread themselves along with doing damage.
How: There are a number of ways to make a computer virus. I've read that there are toolkits to make viruses (i.e. point and click various options in the toolkit to create your own computer virus) but haven't ever seen one. Most viruses tend to be written in assembler and the latest incarnations are polymorphic in nature (the code changes itself for every system to make them harder to detect and remove). Although, a simple virus could be written in any language - but assembler is preferred because it reduces the ability to trace the origin to the author.
Why: The most common reason: Curious teenage boys who have nothing better to do get bored and think it would be "cool" to inflict their own virus on people. Sometimes software vulnerability researchers will release proof-of-concept code when the software manufacturer refuses to fix bugs - the end result from someone significantly more malicious than the researcher is usually a particularly nasty worm. And some people are just plain evil.
Also, there are people out there who actually _collect_ and _swap_ computer viruses (something akin to collecting and trading baseball cards). A virus is just a bunch of 0's and 1's after all - as long as it doesn't get executed, it is perfectly innocuous.