Ashura was a day that the Quraysh used to fast during the days of ignorance, and the Messenger of Allah ﷺ used to fast it as well. When he arrived in Madinah, he continued to fast it and instructed the people to fast it. Then, when the fast of Ramadan was made obligatory, Ramadan became the required fast and Ashura was left optional. Whoever wished could fast it, and whoever wished could leave it.
حدثنا هارون بن إسحق الهمداني حدثنا عبدة بن سليمان عن هشام بن عروة عن أبيه
كان عاشوراء يوما تصومه قريش في الجاهلية وكان رسول الله ﷺ يصومه فلما قدم المدينة صامه وأمر الناس بصيامه فلما افترض رمضان كان رمضان هو الفريضة وترك عاشوراء فمن شاء صامه ومن شاء تركه
Agreed upon. Bukhari transmitted it in the Book of Fasting, chapter on fasting the day of Ashura, no. 2002, and Muslim in the Book of Fasting, chapter on fasting the day of Ashura, no. 1125, both from the hadith of Hisham bin Urwa through this route.This subject is also reported from Ibn Masud [Bukhari, no. 4503, and Muslim, no. 1127], Qays bin Saad [Nasai, no. 2508], Jabir bin Samura [Muslim, no. 1128], Ibn Umar [Bukhari, no. 4501, and Muslim, no. 1126], and Muawiya [Bukhari, no. 2003, and Muslim, no. 1129].