It used to be the general practice of the Messenger of Allah, Peace and blessings be upon him, to perform Itikaaf in the Holy month of Ramadan. At times, he used to remain in the masjid for the whole month and in the year of his demise, he was in Itikaaf for twenty days. Because he usually secluded himself in the masjid for the last ten days of Ramadan, the ulama consider it a Sunnah to perform Itikaf for that period.
Ibn Abbas relates that the Messenger of Allah, Peace and blessings be upon him, said, “The person performing Itikaaf remains free from sins and he is indeed given the same reward as those who do good deeds (despite not having done these deeds). (Ibn Majah)
This hadith mentions two great benefits of Itikaaf. The first is that the person performing Itikaaf avoids sins. The world around us is full of temptations, and more often than not, one falls into them. To commit sins in this blessed month is indeed a great injustice to ourselves. Through remaining secluded in the masjid, one completely avoids the temptation of sinning.

