The Prophet ﷺ said, "Whoever strokes the head of an orphan boy or girl, doing so for no reason other than Allah, will receive good deeds for every hair his hand passes over. And whoever treats well an orphan girl or boy under his care, he and I will be in Paradise like these two," and he held his two fingers together.
حدثنا علي بن إسحاق أخبرنا ابن المبارك حدثنا يحيى بن أيوب عن عبيد الله بن زحر عن علي بن يزيد عن القاسم
عن النبي ﷺ قال من مسح رأس يتيم أو يتيمة لم يمسحه إلا لله كان له بكل شعرة مرت عليها يده حسنات ومن أحسن إلى يتيمة أو يتيم عنده كنت أنا وهو في الجنة كهاتين وقرن بين أصبعيه
Its chain of transmission is hasan. It is found in Tabarani's Al-Kabir 8/239, no. 7821, and Haythami graded it daif 8/160.