Suuratul Maidah Verse 105.
يَـٰٓأَيُّهَا ٱلَّذِينَ ءَامَنُوا۟ عَلَيْكُمْ أَنفُسَكُمْ ۖ لَا يَضُرُّكُم مَّن ضَلَّ إِذَا ٱهْتَدَيْتُمْ ۚ إِلَى ٱللَّـهِ مَرْجِعُكُمْ جَمِيعًا فَيُنَبِّئُكُم بِمَا كُنتُمْ تَعْمَلُونَ ﴿١٠٥
105. O you who believe! Take care of your ownselves, no hurt can come to you from those who are in error. The return of you all is to Allah, then He will inform you about (all) that which you used to do.
Tafsir Ibn Kathir Volume 3, Page 289.
Allah commands His believing servants to reform themselves and to do as many righteous deeds as possible. He also informs them that whoever reforms himself, he would not be affected by the wickedness of the wicked, whether they were his relatives or otherwise. Imam Ahmad recorded that Qays said, “Abu Bakr As-Siddiq stood up, thanked Allah and praised Him and then said, `O people! You read this Ayah,
﴿يأَيُّهَا الَّذِينَ ءَامَنُواْ عَلَيْكُمْ أَنْفُسَكُمْ لاَ يَضُرُّكُمْ مَّن ضَلَّ إِذَا اهْتَدَيْتُمْ﴾
(O you who believe! Take care of yourselves. If you follow the right guidance, no hurt can come to you from those who are in error.) You explain it the wrong way. I heard the Messenger of Allah say,
«إِنَّ النَّاسَ إِذَا رَأَوُا الْمُنْكَرَ وَلَا يُغَيِّرُونَهُ، يُوشِكُ اللهُ عَزَّ وَجَلَّ أَنْ يَعُمَّهُمْ بِعِقَابِه
(If the people witness evil and do not change it, then Allah is about to send His punishment to encompass them.) I (Qays) also heard Abu Bakr say, `O people! Beware of lying, for lying contradicts faith.”’