Some write for fun...
Some write for experiment
Some write without the intent that it will actually get sent out. (Thats why they make viruses that purposely spread from machine to machine)
Some do to say they can (this is very very common)
Other than that, they usually run and compile viruses on a test machine... loosing none of their data.
Pretty good for them, isnt it?
Want me to write one so you can send it to the jerk who infected you? I bet all he will do is write another one and send it back. (Nah, I wouldn't do that. But, I can write an incredibly sucky one... wait! They all suck!)