Context is important in reading Scripture. Here’s the rest of what those verses say (bold emphasis is mine):
“Slaves, be obedient to those who are your earthly masters, with fear and trembling, in singleness of heart, as to Christ; not in the way of eye-service, as men-pleasers, but as servants of Christ, doing the will of God from the heart, rendering service with a good will as to the Lord and not to men, knowing that whatever good any one does, he will receive the same again from the Lord, whether he is a slave or free.
Masters, do the same to them, and forbear threatening, knowing that he who is both their Master and yours is in heaven, and that there is no partiality with him.” -Ephesians 6:5-9
“Slaves, obey in everything those who are your earthly masters, not with eyeservice, as men-pleasers, but in singleness of heart, fearing the Lord. Whatever your task, work heartily, as serving the Lord and not men, knowing that from the Lord you will receive the inheritance as your reward; you are serving the Lord Christ. For the wrongdoer will be paid back for the wrong he has done, and there is no partiality.
Masters, treat your slaves justly and fairly, knowing that you also have a Master in heaven.”
Saint Paul was not advocating for slavery. He was addressing slaves and masters of slaves and telling them how they should treat one another. And Peter was saying that when we suffer we should do it as Christ did. This principle of enduring suffering with patience for the sake of the Kingdom is Christ’s teaching that we should love our enemies. It’s a universal principle that applies to all Christians. One of the Pope’s official titles is “Servant of the Servants of God.” All Christians are called to humility and service and to love those who persecute us. Loving our enemies is what distinguishes Christians from the pagans. And this extraordinary virtue is what impressed the pagans in the early Church so much that many of them became Christians. This is how Christianity was spread without a revolt.
“So the last will be first, and the first last” - Matthew 20:16