The people of the pre-Islamic era used to fast on the day of Ashura, and the Messenger of Allah ﷺ and the Muslims fasted it before the fast of Ramadan was made obligatory. When Ramadan was made obligatory, the Messenger of Allah ﷺ said, "Ashura is one of the days of Allah, so whoever wishes may fast it, and whoever wishes may leave it."
حدثنا أبو بكر بن أبي شيبة حدثنا عبد الله بن نمير ح و حدثنا ابن نمير واللفظ له حدثنا أبي حدثنا عبيد الله عن نافع أخبرني
أن أهل الجاهلية كانوا يصومون يوم عاشوراء وأن رسول الله ﷺ صامه والمسلمون قبل أن يفترض رمضان فلما افترض رمضان قال رسول الله ﷺ إن عاشوراء يوم من أيام الله فمن شاء صامه ومن شاء تركه