Replacing one day of fast of Ramadan or making up for Ramadan (obligatory fast) if one has broken his fast due to a valid reason actually is covered in the qur'an in (2:184).
But if one had intercourse intenionally while fasting the kaffara (expiation) is presented in the following hadith:
While we were sitting with the Prophet (ﷺ) a man came and said, "O Allah's Messenger (ﷺ)! I have been ruined." Allah's Messenger (ﷺ) asked what was the matter with him. He replied "I had sexual intercourse with my wife while I was fasting." Allah's Messenger (ﷺ) asked him, "Can you afford to manumit a slave?" He replied in the negative. Allah's Messenger (ﷺ) asked him, "Can you fast for two successive months?" He replied in the negative. The Prophet (ﷺ) asked him, "Can you afford to feed sixty poor persons?" He replied in the negative. The Prophet (ﷺ) kept silent and while we were in that state, a big basket full of dates was brought to the Prophet (ﷺ) . He asked, "Where is the questioner?" He replied, "I (am here)." The Prophet (ﷺ) said (to him), "Take this (basket of dates) and give it in charity." The man said, "Should I give it to a person poorer than I? By Allah; there is no family between its (i.e. Medina's) two mountains who are poorer than I." The Prophet (ﷺ) smiled till his premolar teeth became visible and then said, 'Feed your family with it."
it is either to free a slave, to fast two consecutive months or feed 60 poor people for each day after repenting. Note that there are details on whether both man and woman or only one of them needs to perform a severe expiation.
Via qiyas (analogy) the hanafis and malikis applied this also to a person who deliberately broke his fast by eating or drinking as they say both a person who had intercourse and that who ate or drunk on the day of Ramadan didn't respect this month and the order of fasting in it. While other madhhabs in the later case didn't ask to make up more than one day.