The day of Ashura was a day that the Quraysh used to fast during the pre-Islamic era, and the Messenger of Allah ﷺ also used to fast it. When he arrived in Medina, he continued to fast it and ordered others to fast it as well. When the fasting of Ramadan was prescribed, Ramadan became the obligation and Ashura was left optional. Whoever wished could fast it, and whoever wished could leave it.
حدثنا ابن نمير ويحيى عن هشام قال أخبرني أبي
كان يوم عاشوراء يوما تصومه قريش في الجاهلية وكان رسول الله ﷺ يصومه فلما قدم المدينة صامه وأمر بصيامه فلما نزل صوم رمضان كان رمضان هو الفريضة وترك عاشوراء فكان من شاء صامه ومن شاء لم يصمه