In Shakespearean times they used to bite their thumb at people (the whole first scene of Romeo and Juliet involves a fight over this obscene gesture). I'm not sure if thumbing your nose at someone evolved from that same gesture, but it's a possibility. At the very least, biting your thumb at someone is a disrespectful gesture that is at least 500 years old.