In a lot of books in the Bible, the number 40 keeps appearing. E.g. Jesus went into the desert for 40 days and nights, and the Jews spent 40 years looking for the promised land. Is this because of some significance of the number 40, or is it just coincidence?
Emanuel Swedenborg (1688–1772) interprets the number 40, and related numbers in the Bible, as having three key meanings, often combined, based on the usage of the number 40 throughout the Bible:
- Something lasting a full measure until completeness
- A period of trial and temptation
- A process of devastation or emptying out of evil
"Devastation" (traditionally "vastation") as Swedenborg's uses the word, is closely connected with spiritual trial and temptation. The very purpose of temptations—which are spiritual struggles and battles—is to weaken and empty out the evil and falsity that has a person, nation, or church in its grip in order to make room for good and truth from God to flow in and replace it. Until the existing evil and falsity has been emptied out, there is no room for God's goodness, truth, love, and wisdom, and therefore no possibility of salvation.
So the periods of trial and temptation commonly represented by 40, as harrowing, painful, and depressing as they may be, are absolutely necessary for our eternal salvation.
For people, nations, and churches that are implacably evil and unwilling to repent, this spiritual devastation leads to the ultimate judgment and destruction of a nation or church, or to the death and consignment to hell of an individual.
But for people, nations, and churches that are willing to repent and begin a new life in obedience to God's commandments, this period of spiritual devastation leads to the rejection of former evil desires, false beliefs, and wrong action, and their replacement with goodwill (meaning love for God and the neighbor), understanding of genuine truth, and right action, or "righteousness" in biblical terms.
As shown in the commentaries quoted below, though the number 40 in the Bible sometimes means simply full measure until completeness, more commonly it combines all three meanings, of full measure until completeness, of trial and temptation, and of the devastation and emptying out of evil of an individual, nation, or church.
Here are two key passages from Arcana Coelestia ("Secrets of Heaven"), Swedenborg's eight volume (in the original Latin edition) commentary on the books of Genesis and Exodus, in which he details these meanings, providing many references and quotes from the Bible where these meanings show clearly. Numeric references are to other sections in the same work, here linked for convenience.
The first passage quoted is from an older translation. For reference, "the Word" here means the Bible, and "influx" means a flowing in of God's presence, or of divine truth and divine love.
In the first passage the commentary focuses on the first meaning of 40 listed above, that of completeness.
"And Moses was on the mountain forty days and forty nights" [Exodus 24:18] means the instructions given and influx in their completeness. This is clear from the meaning of "forty" as completeness. "Forty" means completeness because "four" means that which is complete, 9103, as similarly does "ten," 3107, 4638, and forty is the product of four multiplied by ten. For compound numbers have a meaning similar to the simple numbers of which they are the product, 5291, 5335, 5708, 7973; and all numbers in the Word mean spiritual realities, see 575, 3252, 4264, 4495, 4670, 5265, 6175. All this goes to explain why Moses was on the mountain forty days and forty nights. The fact that "forty" here means the instructions given and the influx in their completeness is evident from Chapters 25-32 which come next, recording the instructions Moses received, that is, instructions regarding the ark, Aaron, the urim and thummim, and sacrifices. The reason why influx in its completeness is also meant is that at that time Moses began to represent the outward holiness of the Word, which acted as the intermediary between the Lord and the people, and mediation is accomplished by means of influx through that holiness into the representative existing among that people, 9419.
 It was because "forty" represented completeness that Moses remained on Mount Sinai forty days and forty nights not only this time but also on another occasion, Exodus 34:28; Deuteronomy 9:18, 25; 10:10. For the same reason the children of Israel wandered in the wilderness forty years until, as it says in Numbers 14:33, 34; 32:13, all that generation had been consumed; Jonah told the Ninevites that their city would be overturned after forty days, Jonah 3:4; the prophet was commanded to lie on his right side and bear the iniquity of the house of Judah forty days, Ezekiel 4:6; it says regarding Egypt that it would be made completely desolate for forty years, after which they would be gathered from the peoples, Ezekiel 29:11-13; and the earth was rained on forty days and forty nights, so that it was inundated with the flood, Genesis 7:4, 12, 17. From all this it is evident why the wicked person was to receive forty blows, Deuteronomy 25:3, for "forty blows" meant the punishment in its completeness. It is also evident what should be understood in the prophecy of Deborah and Barak when it says that no shield or spear was seen among the forty thousand of Israel, Judges 5:8, "among the forty thousand of Israel" meaning among them all. It is in addition evident why the temple built by Solomon was forty cubits long, 1 Kings 6:17, as was the new temple, according to Ezekiel 41:2; for in the highest sense "the temple" means the Lord, and in the internal sense heaven and the Church, so that "forty" means completeness in respect of representation. And it has a like meaning in other places. (Arcana Coelestia #9437, links added)
And an even more extensive explanation from earlier section in the same work, from a more contemporary translation.
In this second passage, the commentary focuses more on the second and third meanings of 40 given above: of trial (traditionally "temptation"), and of devastation or emptying out of evil, while still retaining the first meaning relating to the full measure and completeness of those trials and devastations.
The fact that forty days and nights is a symbol for how long their trials last stands out clearly from the Lord’s Word.
The use of forty as a symbol for the length that times of trial last comes from the fact that the Lord submitted to being tested for forty days, as shown in Matthew 4:1–2; Luke 4:2; and Mark 1:13. Each and every tradition established in the Jewish church, and in all the other representative churches that preceded the Lord’s Coming, foreshadowed him. So the forty days and nights did too, representing and symbolizing every time of struggle in general, and the length that any one time of struggle lasts in particular.
When we are being tried, we experience the devastation or stripping away of everything self-centered and bodily. What is self-centered and bodily has to die—and die through combat and struggle—before we can be reborn as a new being, or in other words, as a spiritual and heavenly being. Because of this, forty days and nights also symbolize the length of time that devastation lasts. They do so here, in a verse that deals with both the trials of the people in the new church known as Noah and the devastation of the pre-Flood people.
 The symbolism of forty as the duration of both trials and devastation, whether long or short, can be seen in Ezekiel:
You shall lie on your right side and carry the wickedness of the house of Judah forty days; a day for each year is the [task] I have set for you. (Ezekiel 4:6)
Forty stands for the length of time the devastation of the Jewish church lasted. It stands also as a representation of the Lord’s struggles, since it says that he was to carry the wickedness of the house of Judah. In the same author:
I will turn the land of Egypt into wastelands, a ruinous wasteland. It will not be traversed by a human foot, nor will an animal’s foot traverse it, and it will not be inhabited for forty years. And I will make the land of Egypt a ruin in the middle of ruined lands; and its cities in the midst of wasted cities will be a lonely place for forty years. (Ezekiel 29:10–12)
Again forty stands for the time it takes for them to be devastated (or laid waste) and ruined. On a deeper plane it positively does not mean forty years but only the overall process by which faith is brought to ruin, whether this takes a short or long time. In John:
Throw out the courtyard that is outside the temple and do not measure it, because it has been given to the nations, which will trample the holy city for forty-two months. (Revelation 11:2)
 And in the same author:
The beast was given a mouth speaking grand things and blasphemies, and it was given authority to act for forty-two months. (Revelation 13:5)
Here the number stands for the course that devastation runs, since it certainly does not mean a period of forty-two months, as anyone can see. This time the number mentioned is forty-two, which is the same as forty, for the following reason. Seven days symbolize the end of devastation and a new start while six symbolizes hard work, from the six days of labor or combat. Seven multiplied by six, then, produces forty-two, symbolizing the length of time devastation lasts and the length of time struggles or labor and conflict last for those who are being reborn. This period contains something holy. The round number of forty is a substitute for the exact figure of forty-two, as is clear from the above places in the Book of Revelation.
 The fact that the Israelite people wandered in the wilderness for forty years before entering the land of Canaan likewise represented and symbolized the duration of hardship and also of devastation. The former was represented and symbolized by the fact that they did eventually enter the holy land. The latter was represented and symbolized by the fact that everyone who had passed the age of twenty by the time of leaving Egypt, except for Joshua and Caleb, died in the wilderness. Hardships are meant by the things against which the people murmured so many times, and devastation is meant by the plagues and deaths that so often struck.
The symbolism of these events as trials and devastation will be shown where the relevant passages are explained, the Lord’s divine mercy permitting. Moses speaks of them this way:
Remember all the path that Jehovah your God led you on these forty years in the wilderness to afflict you, to test you, to know what was in your heart, whether you would keep his commandments or not. (Deuteronomy 8:2–3, 16)
Moses’ forty days and forty nights on Mount Sinai are again a symbol for the length of time that struggle lasts, or for the testing of the Lord, as is clear in Moses:
He was on Mount Sinai forty days and forty nights, not eating bread, not drinking water, pleading for the people that they not be destroyed. (Deuteronomy 9:9, 11, 18, 25–29; 10:10; Numbers 14:33–35; 32:8–14)
 The reason forty days symbolize the duration of struggles, as noted, is that the Lord allowed himself to be tried by the Devil for forty days. Since everything represented the Lord, if the angels were thinking about trial, that idea was represented visually in the world of spirits by the kinds of things that exist in the world. All the thoughts angels have are made visible in representative form when they pass down into the world of spirits. So the number forty served for the idea of adversity, since the Lord would struggle for forty days. (To the Lord, and consequently to the angels in heaven, the future is the same as the present. What is to come is already here, or what will happen is already an accomplished fact.) This is why the number forty in the representative church was able to represent times of trial, and of devastation as well. (Secrets of Heaven #730, italics added)
Another extensive commentary on the number 40 and related numbers throughout the Bible is found in Swedenborg's posthumously published work Apocalypse Explained, #633.
A child is born in the 40th week.
Hence children of Israel tempted 40 years in the wilderness before being delivered into the promised land.
And Matthew is the 40th book.
There are larger patterns than this. Moses was 40 days in the mount, and went up twice, so there is a 40+40 pattern.
This pattern is in the 40+40+40 lifespan of Moses.
And I suggest this may also connected with the jubilee periods between Abram, Jesus and his return, which also fit a similar pattern. Study of the AV's internal witness may help discern.
As a young boy I was told that the number 40 signified a generation. The number 40 is also used by God to represent a period of testing or judgment.
The number forty is used by God to represent a period of testing or judgment (the length of time necessary to accomplish some major part of Gods plan in his dealings with various portions of mankind). The 40 days of rain in the days of the flood were the judgments of God. The 40 day periods of fasting, testing, and communing with God that were faced by Moses and Jesus were a form of God's judgments. The forty years that the Israelites spent in the wilderness were also the judgments of God. Various leaders in Israel who reigned for 40 year periods were put there BY God according to His Will and Judgments. Egypt was left desolate for 40 years because of God's judgments.
We can easily see from Numbers 32:13 and Hebrews 3:8-10 that God calls 40 years a generation. Matthew 1:17: from captivity in Babylon (586 BC) until Christ is 14 generations. 586 BC to Christ' birth is 586 years, divided by 14 is 41 years. This is important, as it will benefit us in studying the meaning of Jesus' words in Matthew 23:36; 24:34, Mark 13:30, and Luke 21:32.
We are about to put some biblical pieces together in a puzzle that can solve a lot of unknowns and uncertainties in some major doctrinal areas. Let us look at the "pieces" we have figured out so far: 1) The number 40 has to do with God's judgments. 2) God speaks of a generation as 40 years. 3) Jesus speaks of judgments that will come upon a particular generation of the literal Jews.
We find the most significant numerological type of all in one of the most striking events in the account of Scripture - the forty years of wilderness wandering leading up to the possession of the temporal land of promise. In fact, Paul himself wrote that the surrounding events of the wilderness wandering "were our examples" (I Corinthians 10:6), and that "they are written for our admonition, upon whom the ends of the world (aion-age) have come" (verse 11). It is this event which presents the clearest correspondences to the redemptive work of Christ, and the time-frame of its fulfillment.
To be more specific, the exodus out of Egypt and into the promised land, by the children of Israel under Moses, is a direct shadow of the exodus of the New Testamentary generation from the cross to the entrance into the eternal land of rest. We will see a number of similarities between the two; not only in the area of principles and concepts, but also in the chronological time-frame of the periods under consideration. - The Significance of the Number 40