Note: this is a weak Hadith. It’s been classified as weak by Al-Albani see here. If you come across an Islamophobe asking you to explain it, tell them it is weak.
A man from the Ansar called Basrah said:
Although it’s weak, there some explanation of the statement “the child will be your slave”:
The meaning of ” take the born child as your slave” has been explained by al-khattabi who said, ” I know no scholar who disgaree with the freedom of the child who came through adultery when the mother is free woman. Thus, the meaning of this statement , if this narration is proven authentic, that the prophet wanted him to look after the child and raise him well so and in return the child will serve hi like a slave due to his goodness and kindness towards him”.
See here for more discussion and explanation of this weak hadith here: