The Messenger of Allah ﷺ said, "When Allah intends good for a servant, He puts him to use."They asked, "How does He put him to use?"He replied, "He grants him success in performing a righteous deed before his death."
حدثنا ابن أبي عدي عن حميد
قال رسول الله ﷺ إذا أراد الله بعبد خيرا استعمله قالوا وكيف يستعمله قال يوفقه لعمل صالح قبل موته
Its isnad is sahih. Haythami said in 7/214, "The men of Ahmad are the men of Sahih." Ibn Hibban also narrated it, 450, no. 1821 of Al-Mawarid, as did Hakim, 1/340, who graded it sahih, and Dhahabi agreed with him. It is found with similar wording in Tirmidhi, 4/450, no. 2142, where he said, "Hasan sahih." It is also in Malik, 2/899, in the chapter on qadar, on the prohibition of speaking about qadar.