Several times within the Old and New Testament of the Bible there are notes pertaining to a long time as "40 days," as in 40 days of fasting, rain, traveling, etc. Why 40? Is there a factual association? The only thing I've noticed are references to 40 days needed for mummification in natron. Any insight? Thanks!
I believe it to be an euphemism similar to how today one might say something like gazillions for a large number.
In a society that is mostly innumerate as well as illiterate, where neither pencils nor paper exist and both slateboards and chalk are fragile and rare, the scale of numbers readily accessible to the common population are much smaller than today. The meaning of 40 to me comes across as: "longer than a month, and more days than one would care to count"; or as Wikepedia puts it in that link:
similar to "umpteen".
There is push-back in the comments about my use of the word euphemism above. I stand by that usage. The 1928 edition of the Oxford English Dictionary provides, as an exemplification of (proper) usage, the following from Fur Animals: by Eliott Coues, 1877: (p. 216, start of paragraph)
The skunk yields a handsome fur, lately become fashionable, under the euphemism of Alaska Sable - for our elegant dames would surely not deck themselves in obscene Skunk skins if they were not permitted to call the rose by some other name.
The softening of an exact, possibly estimated, number by the more general and de-nerded forty seems quite inline with Coues' usage.
In a discussion below it became clear to me that I have relied above on a physicist's deep distinction between Accuracy and precision - without making that explicit.
In the context of this discussion, one might regard precision as the choice between hours, days, weeks and months as the unit of measure. Accuracy would be the determination of whether, in the unit of measure chosen, the value specified is the most correct possible, in that unit of measure.
SO the use of the phrase "forty days" appears to be specified with an accuracy determined in days; but actually intends, by convention, an accuracy in months. It means:
"many days, longer than a month, but shorter than many months".
Retaining the connotation of "many" above is important to imbue the sense of "trial" described below by David:
enough time passed for God to achieve a goal. Fullness of time.
Conveniently the number of days in a month (29 or 30) and the number of years in a generation (25 to 30) are close enough so that the quantity 40 is situated comfortably above one and below two such, and is a multiple of 10. This makes it particularly suited to the usage described above, whether days/months or years/generations are the units of measure at issue.
There seems to be a bit of pushback on Pieter's (correct) answer, so perhaps a bit more detail is in order.
It is not at all uncommon in languages to have words that, while technically a specific number, are usually used just to indicate an unspecified large amount. One of the technical terms for this is non-numerical vague quantifiers.
The most well-known of these is of course the Hebrew Bible's "40", but they also had a word for an even larger indeterminate number: רבבה. This word came into English (via Greek) as "myriad", but the technical literal value for it is 10,000.
Probably the next most famous for us English speakers is 1,001, which came into English from the Arabic work 1,001 Nights (which usually doesn't contain exactly 1,001 stories, unless you get an edition that purposely tried to edit to that amount for some weird reason). You can find all kinds of English-language books with titles on the theme "1,001 Uses For...", and nobody really expects those to contain exactly 1,001 of the thing in question.
Now most secular (and mainline Christian) Biblical scholars will tell you that the earliest written source for the Hebrew scriptures (including the story of Noah that prominently featured the indeterminate 40) committed the stories to writing around the 6th Century BC.
This was about 4 centuries before the Hebrews started using their distinctive Greek-borrowed numeric system (which resembles Roman Numerals a bit in implementation). At that time the numeric system in use would have been the old Babylonian Sexagesimal system. This survives today mostly in our units of time and angle "degree" (and thus Earth surface coordinate) measurements. This was technically a hybrid base 60 system, but represented with a weird base 10 tally system within the 60.
If that sounds complicated to you, you're probably still better off than the common Semite, who as Pieter pointed out, probably didn't really know how to read or use this system themselves beyond the bare basics required for everyday life. Doing reckoning under this system was much harder than what we have today, and there was no equivalent to the modern western education system, where every child gets basic mathematics instruction. Working with numbers that high was difficult, and very few in the audience of these stories would have been trained to do so.
You may notice that the superglyph for 40 specifically is the first one where there isn't enough space for all the 10's tallies on one line, so you have to start compressing them together into 2 lines in the same amount of space. Perhaps its a coincidence, but this is certainly the point where the writing/carving for numbers starts to look like a bit of a mess. Its a lot.
Biblically, Forty is a number associated with testing and trials
Jesus wandered in the wilderness 40 days, Israel wandered in the desert for 40 years etc.
It's a number that indicates enough time passed for God to achieve a goal. Fullness of time.
Motivation for the answer
I'll take a literary approach, aiming less at the surrounding historical context and more at an internal analysis of what "significance" the document's authors intended to convey.
However, rereading your question and David Robinson's comment, I see that you're not asking about this significance so much as the motivation to use "40" specifically. Thus, this answer doesn't directly address your question. But I do believe it provides an important foundation for an answer, because understanding the purpose a tool was used for helps understand the choice of tool.
Both Pieter and T.E.D. offer explanations of the choice of tool, and in that regard the answers will be more satisfactory. But the implied or stated purpose they are based on almost certainly misses the mark. I submit that both traditional and modern biblical scholarship would say it's unlikely that the purpose, the force of using "40" is to have an indeterminate number on hand. It certainly is not a euphemism (there is no social taboo to soften); it certainly is not due to the impossibility or awkwardness of inexpressing bigger numbers with precision or with vagueness (both are done often enough); and the biblical authors were not interested in de-nerding what is in fact a very nerdy document replete with specific numbers both large and small, particularly in the Pentateuch, where we find many of these same narratives that strategically use "40".
Some answers have suggested mathematical reasons for "40", computing percentages or aligning the numbers with other (supposedly) significant values. I find these anachronistic and atypical of biblical narrative structure.1
Pieter's and T.E.D.'s suggestions of a number system cutoff (or significant change) and of averaging out months or lifespans are more likely, more interesting, more basic motivations. But why did the writers (or the speakers of the language they used) look to natural or manmade phenomenon of around that size? Hopefully the discussion below concerning the function of "40" from the perspective of the document helps clarify what the tool is for for any other answerers.
We can make one observation in line with the previous answers, namely that it is almost certainly not a literal but a symbolic value.2 In that sense, it is indeed an "indeterminate" number in that one is not interested in the exact value.
But we can also make the observation that though it may stand for an indeterminate number, it's not exactly an "indeterminately large number" in the sense of "more than one would care to count". The Bible is well aware that 40 is too small a unit for such purposes, and for big, vague numbers it prefers rounded-off hundreds, thousands, tens of thousands, or even hundreds of thousands (Deut 32:30, Josh 23:10, 1 Chron. 12:14, Judges 15:16, Psalm 91:7, 1 Sam. 13:2, 2 Sam. 18:3, Lev. 26:8, 1 Sam. 15:4, Num. 11:21, NT Rev. 7:4, etc.). Hence, reading "gazillions" or even "umpteen" for the biblical 40 seems to miss the mark.3
So does 40 simply mean "an indeterminate small number"? Maybe. After all, it's probably around as small as you can get and still be indeterminate! But I think the Bible has a narrower use for it. There is indeterminacy, but that's not the force of the biblical use.
Significant block of time
One important note is that this number almost uniformly counts a period of time.4
When speaking of years, some instances: The Israelites wandered in the desert 40 years, with the explicit effect being that a whole generation died off (Num. 32:13). Moses fled Egypt at 40 years old (Acts 7:23) and returned 40 years after that (Acts 7:30). Some patriarchs married at 40, including Isaac (Gen. 25:20) and Esau (Gen 26:34). More than one king is said to have ruled for 40 years (e.g. 1 Sam. 4:18). In Jewish tradition, a person is allowed to study the Kabbalah at 40.5
When speaking of days, some instances: Noah's rain fell for 40 days and nights (Gen. 7:4); the spies explored Canaan for 40 days (Num. 13:25); Goliath taunted the Israelites for 40 days (1 Sam 17:16); Moses thrice spent 40 days and nights on Mount Sinai (Deut. 9:11, 9:25, 10:10); Elijah took a journey of 40 days to Mount Horeb (1 Kings 19:8). Embalming a corpse required forty days (Gen 50:3) — cp. your note on natron. In the NT, borrowing from this tradition, Jesus spends 40 days in the wilderness (Matt 4:2) and sticks around for 40 days after resurrection (Acts 1:3).
I would thus offer an interpretation for "40 years" as a single generation in the sense of having lived a full life (in ancient terms!): you are not just the nominal "adult" of your 12/13 years at bat mitzvah or bar mitzvah, but have lived the whole span that most adults enjoy and acquired a certain measure of wisdom and experience by doing so. This fits with the marriages mentioned above; 40 would be a rather old marriage in ancient times, but if it means "having accrued the fullness of age", it makes sense. (As a corrolary, your time is over and it's now your children's time.) It's a unit, a mini-epoch, a building block in a history or geneaology of a nation — which is the sort of thing the Bible is deeply concerned with, even symbolically.
Meanwhile, for "40 days" we can extend and miniaturize that meaning: it's a significant block of time within an average lifespan. We might say that 40 days is to a person's lifetime what 40 years is to a nation's history: a unit of time big enough to mark a change or a significant event.6
Wikipedia tells me this reading is corroborated by Michael Coogan.7
Other commentators, such as Ellicott in the 19th century, identified the number as one indicating "trial and patience", which fits well with the idea of a significant event (but doesn't agree with my focusing on a generation).
Meanwhile, the Pulpit Commentary (also 19th century) cites Trench that it's sometimes a "signature of penalty, affliction" and confession of sin, and other times a sign that "work is completely [and thoroughly] done".
These are widely accepted, established readings, in line with other commentators (except literalists who take "40" to be a precise value). I don't believe there are many who would say that the force or purpose of using "40" is to select an indeterminate number or to suggest that the exact value doesn't matter in a given context. Sure, it doesn't — but that's not the reason they chose "40".
To me these interpretations reinforce the idea of communicating a whole "unit" of time, whether that unit is characterized by trial or by simple "fullness".
1 When I talk about what the Bible "means" by the number I make no reference to supposedly hidden significance such as numerological or mystical interpretations.
2 There are at least three numbers that come up too often and at too useful a time to be coincidence: 7 / 70 (completeness; the root is related to "satiate"), 12 / 144 (traditional number of tribes of Israel, frequently recurrent), and of course 40. Some other lists include more, but the wider the net cast, the less compelling the explanation of function seems to become.
3 As someone who reads Biblical Hebrew daily, I should note that T.E.D. makes a mistake when citing the word רְבָבָה revavah. This word stems from the root רבב r-b-b meaning "to multiply, to become many", and is a good candidate for "indeterminately large number". Wiktionary and other dictionaries' gloss "10,000" does not refer to the "technical, literal value" of revavah but to precisely the figurative value "10,000" carried in early translations such as the KJV.
4 One exception is the number of se'ahs in a mikvah; this correspondence is only established by extrabiblical tradition.
5 Although, as the linked article notes, this appears to be only ambiguously supported by the Talmud.
6 In sacred matters, the Bible does sometimes use the metaphor of a person for a nation, particularly the Israelite nation.
7 Michael David Coogan, A Brief Introduction to the Old Testament: The Hebrew Bible in Its Context, Oxford, 2008, p. 116.