Sure Al-Baqara

2:124

۞ وَإِذِ ٱبْتَلَىٰٓ إِبْرَٰهِۦمَ رَبُّهُۥ بِكَلِمَٰتٍۢ فَأَتَمَّهُنَّ ۖ قَالَ إِنِّى جَاعِلُكَ لِلنَّاسِ إِمَامًۭا ۖ قَالَ وَمِن ذُرِّيَّتِى ۖ قَالَ لَا يَنَالُ عَهْدِى ٱلظَّٰلِمِينَ

Und (gedenkt,) als Ibrahim von seinem Herrn mit Worten geprüft wurde, da befolgte er sie. Er (Allah) sagte: "Ich will dich zu einem Vorbild für die Menschen machen." Er (Ibrahim) sagte: "Und von meiner Nachkommenschaft?" Er sagte: "Mein Bund erstreckt sich nicht auf die Ungerechten."

Tafsir 2:124

The Qur’ān tells us that Allah tested Abraham (peace be upon him) by instructing him to fulfil commandments and obligations. Abraham obeyed, fulfilling the orders completely. Allah told His prophet Abraham that He would make his manners and behaviour an example for people to follow. Abraham asked Allah to make also his descendants leaders who people would be guided by. Allah replied by saying that His promise to him of sacred leadership would not extend to the wrongdoers among his descendants.