Hadithcore
Musnad Ahmad 2623
hasan

It was narrated that Ibn ‘Abbas (رضي الله عنه) said: The Messenger of Allah (ﷺ) said:

"The expiation for sin is regret.” And the Messenger of Allah (ﷺ) said: “If you did not sin, Allah, may He be glorified and exalted, would bring another people who would commit sin so that He could forgive them.”

References1 variant
Arabic/English book
Book 25, Hadith 2623