Sunan Ibn Majah Book 19, Hadith 20
the Messenger of Allah (ﷺ) was asked about illegitimate children. He said: “Two sandals in which I wage Jihad are better than freeing an illegitimate child.”
“O Umair, I have set you free in a good way. I heard the Messenger of Allah (ﷺ) say: 'Any man who frees a slave and does not say anything about his (the slave's) wealth, it belongs to him (the slave).' So tell me, how much wealth do you have?”
Another chain reports a similar hadith.
`Aishah had a male slave and a female slave who were married. She said: “O Messenger of Allah (ﷺ), I want to free them both.” The Messenger of Allah (ﷺ) said: “If you free them, then start with the man before the woman.”