Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
muslim:1667Muḥammad b. Rāfiʿ > ʿAbd al-Razzāq > Maʿmar > Hammām b. Munabbih > Hadhā Mā > Abū Hurayrah

It is good for a slave that he worships Allah well, and serves his master (well). It is good for him.  

مسلم:١٦٦٧وَحَدَّثَنَا مُحَمَّدُ بْنُ رَافِعٍ حَدَّثَنَا عَبْدُ الرَّزَّاقِ حَدَّثَنَا مَعْمَرٌ عَنْ هَمَّامِ بْنِ مُنَبِّهٍ قَالَ هَذَا مَا حَدَّثَنَا أَبُو هُرَيْرَةَ

عَنْ رَسُولِ اللَّهِ ﷺ فَذَكَرَ أَحَادِيثَ مِنْهَا وَقَالَ قَالَ رَسُولُ اللَّهِ ﷺ نِعِمَّا لِلْمَمْلُوكِ أَنْ يُتَوَفَّى يُحْسِنُ عِبَادَةَ اللَّهِ وَصَحَابَةَ سَيِّدِهِ نِعِمَّا لَهُ  


See similar narrations below:

Collected by Aḥmad, Suyūṭī
ahmad:8233

[Machine] And the Messenger of Allah, ﷺ , said: "What a great blessing for a slave to be taken while in the good worship of Allah and the company of His Prophet, what a great blessing for him."  

أحمد:٨٢٣٣

وَقَالَ رَسُولُ اللهِ ﷺ نِعْمَّا لِلْمَمْلُوكِ أَنْ يُتَوَفَّى بِحُسْنِعِبَادَةِ اللهِ وَصَحَابَةِ سَيِّدِهِ نِعِمَّا لَهُ