Giving someone the finger has been an insult throughout history. However, determining how the gesture came about is difficult (especially on the Internet). The most popular version of the origin of the gesture often refers to the Battle of Agincourt and attempts to hint at the origin of the word "fuck" at the same time:

Before the Battle of Agincourt in 1415, the French, anticipating victory over the English, proposed to cut off the middle finger of all captured English soldiers. Without the middle finger it would be impossible to draw the renowned English longbow and therefore be incapable of fighting in the future.

This famous weapon was made of the native English Yew tree, and the act of drawing the longbow was known as "plucking the yew" (or "pluck yew").

Much to the bewilderment of the French, the English won a major upset and began mocking the French by waving their middle fingers at the defeated French, saying, "See, we can still pluck yew! PLUCK YEW!"

Over the years some 'folk etymologies' have grown up around this symbolic gesture. Since 'pluck yew' is rather difficult to say (like "pleasant mother pheasant plucker", which is who you had to go to for the feathers used on the arrows for the longbow), the difficult consonant cluster at the beginning has gradually changed to a labiodental fricative 'F', and thus the words often used in conjunction with the one-finger-salute are mistakenly thought to have something to do with an intimate encounter.

It is also because of the pheasant feathers on the arrows that the symbolic gesture is known as "giving the bird".

This story seems to have originated around 1996 and is generally considered false.

Another popular story involves the Welsh and the wool yarn they manufactured in the 15th century. Allegedly, Welsh wool was spun into an extremely strong yarn, which was thin, yet strong enough for use in English long bows. The result of having thin yarn was that the notch cut into the English arrows could be made very narrow. A problem during wars in this era was that enemy soldiers would return fire with the arrows that were shot at them. The narrow notch of the English arrows made it impossible for French soldiers to reuse them against the English. The tale says that the English attributed this fact to many victories and took to giving the French soldiers the 2-finger salute (the English version of "the finger") after defeating them in battle, referring to the notch in their arrows.

The most believable (probably because it amounts to "we just don't know") seems to be this:

The middle-finger gesture, which apparently has had phallic connotations in every culture in which it has been used, is much older. We know it dates back at least to ancient Greece, where it was referenced in "The Clouds," a play written by Aristophanes in 423 B.C. It was also well known to the Romans, who referred to it variously as digitus infamis ("infamous finger") and digitus impudicus ("indecent finger"). In all likelihood its origins were prehistoric.
Excerpt from "The Clouds":
Socrates: ... Polite society will accept you if you can discriminate, say, between the martial anapest and common dactylic -- sometimes vulgarly called "finger-rhythm."

Strepsiades: Finger-rhythm? I know that.

Socrates: Define it then.

Strepsiades: [Extending his middle finger] Why it's tapping time with this finger. Of course, when I was a boy [raising his phallus], I used to make rhythm with this one.


http://www.knightrealms.com/Forums/showflat.php?Board=social&Number=6132
http://oii.org/cyberu/html/finger.htm
http://urbanlegends.about.com/library/bl-pluck-yew.htm
http://urbanlegends.about.com/gi/dynamic/offsite.htm?site=http://abcnews.go.com/sections/us/DailyNews/wolffiles55.html