Different programmers create computer viruses for different purposes.  Someone's purpose may be destructive and someone's is for the safety. 
Some of the purposes are as follows: 
- To stop the software piracy.
- To entertain the users by displaying interesting messages or pictures.
- To destroy data, information and files.
- To steal data and information.
- To expose their programming ability.
- To earn money.
- Just to be happy by disturbing others.
- To take control of a computer and use it for specific tasks.
- To cripple a computer or network.
