As for the ruling on i’tikaf, it is a “sunnah” according to the consensus of the scholars, and some jurisprudential schools believe that it is a “confirmed sunnah” in the last ten days of Ramadan. It is not exclusive to Ramadan. However, it is popular to do it during that month, especially during the last ten nights, because that was the tradition of our Prophet (pbuh).
A’isha, (may Allah be pleased with her) reported:
“The Prophet (pbuh) used to engage himself in i’tikaf (seclusion for prayers) in the mosque during the last ten nights of Ramadan till he passed away; thereafter, his wives followed this practice after him.” [Bukhari and Muslim]