I would like to know what the significance of the age of 40 years is in Islam? I have heard about the importance of this age in a person's life but could you direct me to any hadith and explanations that discuss this?

Man reaches intellectual maturity at the age of forty
And the same point can be seen in the issue of man's intellectual maturity after forty years of his life in the world; And referring to this issue in the Holy Quran, he says:
‫حَتىَّ إِذَا بَلَغَ أَشُدَّهُ وَ بَلَغَ أَرْبَعِينَ سَنَةً قَالَ رَبّ‏ِ أَوْزِعْنىِ أَنْ أَشْكُرَ نِعْمَتَكَ الَّتىِ أَنْعَمْتَ عَلىَ‏َّ وَ عَلىَ‏ وَالِدَىَّ وَ أَنْ أَعْمَلَ صَالِحًا تَرْضَئهُ وَ أَصْلِحْ لىِ فىِ ذُرِّيَّتىِ  إِنىّ‏ِ تُبْتُ إِلَيْكَ وَ إِنىّ‏ِ مِنَ الْمُسْلِمِين‏‬
(And when a person reaches the stage of complete growth and prosperity and forty years have passed on him, he says: O God, inspire me through your thanks and gratitude for your blessings on me and my parents! And teach me the way of doing righteous deeds that are pleasing and admirable to you! And establish goodness and righteousness among my descendants! It is true that I turned to you and asked for your surrender and your will.)

This verse, he considers the maturity of human beings as the level of intellectual growth and consistency of the soul in managing and observing materials and corruptions at the age of forty. And after this, man uses the experiences and reserves of the past to complete the soul and through happiness and goodness, not to add to his intellectual breadth and capacity.
Therefore, in "Khasal", Saduq narrates from Imam Sadegh (as) that he said:
إنّ العَبدَ لَفي فُسْحَةٍ مِن أمرِه ما بَينَهُ و بينَ أربعينَ سَنةً؛ فإذا بَلَغ أربعينَ سَنةً أوحَي اللهُ عزَّوجلَّ إلَي مَلَئكَتِه: إنّي قد عَمَّرتُ عَبدي عُمرًا فَغَلِّظا و شَدِّدا و تَحَفَّظا و اكتُبا عَليهِ قَليلَ عَمَلِه و كَثيرَهُ و صَغيرَهُ و كَبيرَه!

The servant is forgiven by God until he is forty years old; And when he reached this age, God Almighty sent a revelation to the two rival kingdoms and Atid, who are entrusted with his deeds and actions: I gave my servants enough life to acquire knowledge and intellectual maturity, from now on he "His deeds are not free, be strict with him and record everything that comes to him more or less accurately!"
And a similar narration has been mentioned in "Khasal" by Imam Sadegh (as):
إذا بَلَغ العبدُ ثَلاثًا و ثَلَثينَ سَنةً فَقد بَلَغ أشُدَّهُ؛ و إذا بَلَغَ أربعينَ سَنةً فَقد بَلَغَ مُنتهاهُ

When Abd reaches the age of thirty-three, he attains the rank of physical and mental stability; "And when he reaches the age of forty, his intellect reaches the utmost degree of power and breadth and perception."
Therefore, if a person does not develop the talent of goodness and guidance until the age of forty, it will be difficult for him to reach the stage of happiness and victory; If this hadith is included in Shiite books and in "Revival of Sciences":
إذا بَلَغ الرَّجُلُ أربعينَ سَنةً و لَم يَتُبْ مَسحَ الشَّيطانُ وَجهَهُ بِيَدهِ و قالَ: بِأبي وَجهُ مَن لا يُفْلِح

a person reaches the age of forty and does not return to God, the devil will anoint his forehead and say:" My father,'s sacrifice for you, you will not be saved anymore! "