Number forty is mystic in Theosophy. According to the Islamic culture if someone practices a good deed constantly during forty days, it would be his inseparable attribute and lead to descending of Allah's blessing.
In some religions forty days and forty nights praying has been special position. When Prophet Musa / Moses (pbuh) prayed forty nights; found the ability to hear the words of Allah (SWT),
"And when We appointed a time of forty nights with Musa, then you took the calf (for a god) after him and you were unjust." [Glorious Quran 2:51]
Prophet Muhammad (saw) said, "Whoever dedicates himself to Allah (SWT) for forty days, will find springs of wisdom sprout out of his heart and flow on his tongue." Commemorating of the fortieth day of deeds by their family and giving alms is one of the common customs among some of the Muslims.
The 40th [Arbaeen (Arbayeen) or Chehlum] marks an important turning point in the movement of Karbala (Kerbala). This day, which is no less important to the day of Ashura (Aashura/Ashurah) is important for many reasons - the prime being that the Ahlul Bayt reached the land of Karbala on this day and performed the visitation to Sayyid ash-Shuhada al-Husayn (as) and the loyal family and friends who gave their life for the cause of Islam. Although the historians differ on when this event transpired; some say it was in the same year of the massacre in Karbala in the year 61 AH, whilst other say it was in the following year 62 AH. Whatever the case, the atrocities and difficulties which the family of Prophet Muhammad (saw) was put through in the court of Yazid and the long ride to Karbala culminated on the 20th of Safar on the empty plains of Karbala.
According to most widely accepted traditions, the family of Prophet Muhammad (saw) remained in captivity for about a year in Damascus by Yazid, the Umayyad Caliph. After one year when the ruler of Shaam (Syria) were forced to release them, Bibi Zainab (sa) said to Imam Ali ibn al-Husayn as-Sajjad (as) that she wanted to go back to Karbala to mourn his brother and all the martyrs of Karbala. The same was desired by other women of this caravan and Imam Ali ibn al-Husayn as-Sajjad (as) directed them towards Karbala. The grave of Imam Husayn Ibn Ali (as) was not desolate as some may expect. Rather, as the Ahlul Bayt were approaching Karbala, there were a few people already at the grave, marking his martyrdom with tears. The individual, who had been a companion of Prophet Muhammad (saw) - Jabir ibne Abdullah al-Ansari (who at this point was blind) - along with his assistant (Atiyya bin Saad), had made the trek from Madina to the place of martyrdom of his Imam and master, Imam Husayn Ibn Ali (as). Jabir ibne Abdullah al-Ansari (ra) called out to his Imam, "I testify that you are the son of the Seal of the Prophets, the son of the Master of the Faithful, the son of the inseparable ally of piety, the descendant of guidance." His servant, Atiyya bin Saad noted to him that he could see a caravan of people in the distance and they were approaching this sacred site. As they approached, they realized that this was none other than the caravan of present Imam, Ali ibn al-Husayn as-Sajjad (as) with the other family members and assistants!
The historians note that at this point, Jabir ibne Abdullah al-Ansari (ra) and his assistant, Atiyya bin Saad, moved out of the way so that the women of the Ahlul Bayt and the others could show their grief at the sacred grave in privacy and according to reports, the heads of the martyrs were also buried at this point in time - as before leaving Shaam (Syria), they were given back the sacred heads of the martyrs.