Formally, a piece of program code that makes copies of itself by attaching itself to another program. In practice, program fragment that arranges to spread from system to system without the knowledge or permission of the system owners.
Much bandwidth has been wasted arguing about the difference between a computer virus and a computer worm; the important thing about both is that they spread, and therefore can cause orders of magnitude more trouble than a direct attack or a typical non-spreading Trojan horse. (As an example argument, it's unclear if "Elk Cloner", often called the first virus, was formally a virus or a worm, because it didn't attach itself to a "program", but to the OS.) Here "virus" will be used to refer to both viruses and worms.
Two main ways how viruses spread are by network and by removable media (usually floppy disks). In early days of personal computers, few were connected via networks and people exchanged information and programs on floppies. Viruses therefore were designed to attach themselves to existing programs so that they might be copied and run on other computers. Nowadays, many computers are connencted via the Internet and other networks. Today's viruses, therefore, tend to use network communication (e.g. web servers and email) to spread.
Most viruses written today are macroviruses and are specific to single popular computer program. The most endemic viruses in recent years have been e-mail viruses that spread by e-mailing themselves to the contacts stored in the user's e-mail program (e.g. Microsoft Outlook or Microsoft Outlook Express) under the guise of some innocuous attachment.
The term "computer virus" was first used in print by Fred Cohen (currently on the Web at http://all.net/ and vicinity), in his 1985 PhD thesis. However, the first virus which escaped into the wild was "Elk Cloner", written in 1982 by Rich Skrenta. See http://www.skrenta.com/ for details, including the source code.