Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:2:183

O you who have believed, decreed upon you is fasting as it was decreed upon those before you that you may become righteous -  

O you who believe, prescribed for you, obligatory ˹for you˺, is the Fast, just as it was prescribed for those, communities, that were before you so that you might guard yourselves, against acts of disobedience, for, it ˹the fast˺ curbs the desires that prompt these ˹acts˺.
القرآن:٢:١٨٣

يَا أَيُّهَا الَّذِينَ آمَنُوا كُتِبَ عَلَيْكُمُ الصِّيَامُ كَمَا كُتِبَ عَلَى الَّذِينَ مِنْ قَبْلِكُمْ لَعَلَّكُمْ تَتَّقُونَ  

{يا أيها الذين أمنوا كُتب} فرض {عليكم الصيام كما كتب على الذين من قبلكم} من الأمم {لعلكم تتقون} المعاصي فإنه يكسر الشهوة التي هي مبدؤها.