The Messenger of Allah ﷺ said, "When Allah intends good for a servant, He puts him to use."Someone asked, "How does He put him to use, Messenger of Allah?"He replied, "He grants him success in doing a righteous deed before death."
حدثنا علي بن حجر حدثنا إسمعيل بن جعفر عن حميد
قال رسول الله ﷺ إذا أراد الله بعبد خيرا استعمله فقيل كيف يستعمله يا رسول الله قال يوفقه لعمل صالح قبل الموت
[Sahih]. Ibn Hibban also narrated it, no. 1821, from the hadith of Ali bin Hajar, and Ahmad, 3/106, from the hadith of Humayd Tawil, with the same wording. Hakim graded it sahih according to the standard of the two sheikhs, 12/339, 340, and Dhahabi agreed with him. The hadith has corroborating narrations in Hakim and Ibn Hibban, nos. 1822, 1823, and others.