The forty of trial is not confined to Israel, and the parallels are worth stating carefully because some are borrowings and some are not.
Islam. The Quran gives Moses forty nights at 7:142 and the forty years of wandering at 5:26, and speaks of the person who reaches forty years as having reached full strength at 46:15. Muhammad is traditionally forty when the first revelation comes at Hira; that figure is from the sira literature, principally Ibn Ishaq, rather than from the Quran, and the distinction is worth keeping. Islamic mourning and commemorative practice in many regions marks the fortieth day after a death.
Christian practice. Lent is forty days, attested from the fourth century and referred to in the canons of Nicaea in 325. The forty days between Christmas and Candlemas follow the forty days of purification in Leviticus 12.
Medicine and law. The word quarantine descends from the Venetian quaranta giorni, the forty days for which ships were held offshore during plague, a practice formalised in the Adriatic in the late fourteenth century, Ragusa imposed a thirty-day isolation in 1377 and the period was later extended to forty. The choice of forty was made in a Christian culture where forty was already the standard span of purification, so the medical number inherits the religious one.
Folk usage. The forty thieves of the Arabian Nights and the forty martyrs of Sebaste belong to the same habit of using forty for a large round set.
What forty does not have is a mathematical basis. It is 2 x 2 x 2 x 5, and nothing about that factorisation explains anything. Its authority is entirely traditional, which is unusual for a number this prominent.