Vitamin C (AKA L-ascorbic acid) is a very important nutrient - without it, you develop scurvy. Many plants & animals have the ability to make their own vitamin C from the glucose they eat - but we've lost that ability. We can only store a bit of this water-soluble vitamin, so if it isn't ingested regularly, the body is soon depleted. Scurvy is characterized by bleeding gums & slow-to-heal wounds, liver spots on the skin & weakness.
So what does vitamin C do that's so important? Vitamin C is an important co-factor for a number of enzymes. An enzyme is a large protein in the body that has some activity - they can be catalytic (breaking molecules) or anabolic (adding molecules together). Vitamin C acts as an electron donor to these enzymes - they wouldn't have the energy otherwise to complete their reaction.
For example, without vitamin C, the enzymes that make collagen do not function properly. Collagen is improperly formed, making mucous membranes particularly weak (& prone to bleeding) & essentially "aging" the skin. Vitamin C is also an important co-factor for enzymes that produce neuro-transmitters, which are necessary for the brain to function normally.
As an electron donor, vitamin C also acts as an anti-oxidant. Oxidation is basically damage - which can lead to dysfunction, aging & cancer. Thus, vitamin C helps to reduce free radicals & oxidative stress.
So why should you take vitamin C when you have a cold? Vitamin C is said to "support" the immune system. This is partly true. The immune system produces free radicals & oxidative stress to fight off pathogens that make you sick (this is only one small part of your immune defenses). So the vitamin C protects your body from its own damaging agents while promoting a healthier state in general.
Despite these therapeutic benefits, taking excessive amounts of vitamin C will not help to prevent colds, flus, aging or cancer. In fact, if you take too much at once, you'll get diarrhea - this is because the vitamin is water-soluble & the body is trying to flush out what it doesn't need. Taking the recommended daily allowance (around 90 mg per day) & a bit extra when you feel a cold coming on should be more than sufficient to keep you healthy!