Because forty days is a traditional number of discipline, devotion, and preparation in the Bible. Thus Moses stayed on the Mountain of God forty days (Exodus 24:18 and 34:28), the spies were in the land for forty days (Numbers 13:25), Elijah traveled forty days before he reached the cave where he had his vision (1 Kings 19:8), Nineveh was given forty days to repent (Jonah 3:4), and most importantly, prior to undertaking his ministry, Jesus spent forty days in wilderness praying and fasting (Matthew 4:2).
Since Lent is a period of prayer and fasting, it is fitting for Christians to imitate their Lord with a forty day period. Christ used a forty day period of prayer and fasting to prepare for his ministry, which culminated in his death and resurrection, and thus it is fitting for Christians to imitate him with a forty day period of prayer and fasting to prepare for the celebration of his ministry’s climax, Good Friday (the day of the crucifixion) and Easter Sunday (the day of the resurrection).
Thus the Catechism of the Catholic Church states: “‘For we have not a high priest who is unable to sympathize with our weaknesses, but one who in every respect has been tested as we are, yet without sinning’ [Heb 4:15]. By the solemn forty days of Lent the Church unites herself each year to the mystery of Jesus in the desert.” (CCC 540).