When we read in Matthew's Gospel that Jesus remained in the desert for 40 days and 40 nights, we realize that this is not the first time the number 40 appears in the Bible. In fact, the number 40 occurs over 80 times in the Bible. The frequent repetition is a clue that it is being used as a symbol and not strictly to communicate facts.
Deuteronomy 8:2 tells us about the significance of the number 40: “Remember how for forty years now the LORD, your God, has directed all your journeying in the desert, so as to test you by affliction and find out whether or not it was your intention to keep his commandments.”
In other words, the number 40 represents a significant period of time during which a person's faithfulness is tested and judged or determined. Whereas the Hebrew people were tested in the desert and failed, Jesus is tested in the desert and succeeds.