The number 40 generally symbolizes a period of testing, trial, or probation. The number 40 can also represent a generation of man.
A few examples:
God flooded the earth by having it rain 40 days and nights. (Gen.7:12)
Abraham at first tried to bargain with God not to destroy Sodom and Gomorrah if 40 righteous people were found. (Gen. 18:29)
Both Isaac and Esau were 40 years old when they were first married.
After the patriarch Jacob died in Egypt, the Egyptians spent 40 days embalming his body. (Gen. 50:3)
Moses lived 40 years in Egypt and forty years in the desert before he was selected by God to lead his people out of slavery.
Moses was on Mount Sinai for 40 days and nights on two separate occasions.
Moses sent spies for 40 days to spy out the land God had promised the Israelites as an inheritance.
The prophet Jonah warned ancient Nineveh for 40 days.
The prophet Ezekiel laid on his right side for 40 days to symbolize Judah’s sins. (Ezekiel 4:6)
Many of the judges and kings served 40 years.
Elijah went 40 days without food or water at Mount Horeb.
Jesus fasted 40 days and nights. (Matt) 4:2)
Jesus was seen of the apostles 40 days after his resurrection before his ascension back to heaven. (Acts 1:2ff)
Hebrews chapter 3 teaches a lesson for today that God was displeased with Israel 40 years in the wilderness for their rebellion and unbelief.