In Deut. 23:15 it says to not return slaves to their masters. But then why in the letter to Philemon does Paul command Onesimus to return to his master?
The passage in Deuteronomy 23 reads:
Deut. 23:15 “You shall not hand over to his master a slave who has escaped from his master to you.
Deut. 23:16 “He shall live with you in your midst, in the place which he shall choose in one of your towns where it pleases him; you shall not mistreat him.
This law required that an escaped slave who sought refuge in Israel would receive protection. It’s important to note that the slave was still to remain a slave, though he was taken in by a new master. The Lord made accommodation for a slave seeking refuge from evil masters or other harsh situations, but the Lord was not freeing the slave. In effect, the prior master forfeited his right to the slave by his mistreatment. Notice in v.16 the Lord required that the new master not mistreat the slave (presumably as the old master had done).
Obviously, Deut. 23 is addressing a very different situation than in the case of Onesimus, who illegally abandoned his service to his master without cause, which was against Roman law and likely why he was imprisoned. Paul commanded the newly-believing Onesimus to resubmit to his master, which was the proper thing to do.
So Deut 23. and Paul’s letter to Philemon are dealing with very different situations.