First, on 666, please note: Straight Dope Staff Report: What’s up with 666?.
I think most likely that what came first was the idea of “important” or “magic” numbers which then became incorporated into literature. Most of these ideas (for Westerners, I can’t speak for China) came from ancient Babylon, from their studies of astronomy. As Alive at Both Ends comments, seven was related to the moon’s phases and so would have been viewed as an “important” number, several centuries before the bible was written (regardless of when one argues that the bible was written.)
Twelve was also a “magic number.” The earliest ancient Babylonians thought there were 360 days in the year (12 months of 30 days) – they did figure out their error later, but the importance of 12s comes down to us an important number. And 12 was important from a pure number-theory point of view, because it has so many factors. Today, we have 12 inches to the foot, 12 months in the year, 12 signs of the zodiac, etc. It’s not surprising then that there would be 12 tribes of Israel, 12 disciples, etc.
Ten is also a number of completeness, presumably from ten fingers and ten toes. Thus, in the bible, ten commandments, ten plagues, etc. And then one gets combinations: Moses lives to 120 years (12 x 10), there are 70 (7 x 10) nations descended from Noah, etc.
On 'tother hand, the number 40 is used in the bible as a reference to generational change (or to the emergence of a new world): 40 days of the flood, 40 years in the wilderness, etc etc. This is, I think, a case where there number 40 had literary significance, rather than arising from any astronomy or other influence.
Footnote: Mahaloth, your interpretation of six days of creation are interesting, but the general folklore in both Jewish and Christian tradition has been that seven represents completeness (on the seventh day, God created the sabbath to complete creation) and that six represents incompleteness.