How to keep your system safe
A computer virus is a program that is embedded with a seemingly safe program that when run will produce copies of itself and then embeds into other files or programs which will then perform some sort of malicious damage (like destroying data).
For a virus to replicate it has to be able to execute code and write to memory, this is why they embed themselves in legitimate programs. If the user executes an infected program the virus may be executed at the same time.
Viruses can be split into two different types depending on what happens once executed, a non-resident virus consists of a finder and replication component, the finders job is to find other files to infect, once it has found an executable file to infect it calls upon the replication component to infect it. Resident viruses, however, only contain a replication component which can be similar to the one used by a non-resident virus, this component is not called by a finder component, the virus loads the replication component into memory and makes sure it loads every time the operating system is started and will infect any suitable programs that are run on the computer.
Computer viruses are always man made, however, once they have been created and released they are not under control and will spread like human viruses, but rather than human to human, they spread computer to computer.