The day of Ashura was a day that the Quraysh used to fast in the pre-Islamic era, and the Prophet ﷺ used to fast it. When he arrived in Medina, he fasted it and ordered others to fast it. Then when Ramadan was prescribed, whoever wished fasted it, and whoever wished did not fast it.
حدثنا مسدد حدثنا يحيى حدثنا هشام قال حدثني أبي
كان يوم عاشوراء يوما تصومه قريش في الجاهلية وكان النبي ﷺ يصومه فلما قدم المدينة صامه وأمر بصيامه فلما نزل رمضان كان من شاء صامه ومن شاء لا يصومه