God Intentionally Kept Moses in the Mount for 40 Days
Exodus 24:18 And Moses went into the midst of the cloud, and gat him up into the mount: and Moses was in the mount forty days and forty nights.
God definitely did not require 40 days to write out His law and give it to Moses. God intentionally kept Moses on the mount for that period of time. It was designed by God as a deliberate test for all of the Jews that came out of Egypt. God knew their hearts. And He knew what a little bit of trying them would produce.
Likewise, God designed these days after the tribulation for practically the same purpose. Obviously, it isn't necessary for God to take 40 years in carrying out His judgment on the church and the world (beginning in 1994 until 2033 is 40 inclusive years). But He designed it this way in order to prove and try those who claim to be His people.
Deuteronomy 8:2 And thou shalt remember all the way which the LORD thy God led thee these forty years in the wilderness, to humble thee, and to prove thee, to know what was in thine heart, whether thou wouldest keep his commandments, or no.