This type of behavior is mentioned in the scriptures.  Matthew 23:1-3 says, “Then spake Jesus to the multitude, and to his disciples, Saying, The scribes and the Pharisees sit in Moses’ seat: All therefore whatsoever they bid you observe, that observe and do; but do not ye after their works: for they say, and do not.”  These scribes and Pharisees sat in “Moses’ seat”.  That is, they were interpreters and teachers of the law given by Moses.  According to what the Lord Jesus said, these men properly taught the truth, although they did not follow their own teachings.  “They say, and do not.”  The Lord instructed the multitude to obey the truth, even though it was being taught by unfaithful men. 

The Apostle Paul spoke of his sufferings and imprisonment in Philippians 1:12-13, “But I would ye should understand, brethren, that the things which happened unto me have fallen out rather unto the furtherance of the gospel; So that my bonds in Christ are manifest in all the palace, and in all other places.”  Paul rejoiced that his sufferings caused the Gospel to expand to many places.  He went on to point out that many preached the Gospel in genuineness, but some preached “not sincerely, supposing to add affliction to my bonds.” (Verse 16).  What was Paul’s conclusion about this insincere preaching?  “What then? notwithstanding, every way, whether in pretence, or in truth, Christ is preached; and I therein do rejoice, yea, and will rejoice. For I know that this shall turn to my salvation through your prayer, and the supply of the Spirit of Jesus Christ.” (Verses 18-19).  To Paul, it did not matter that some were preaching the Gospel in great hypocrisy.  The Gospel was being preached and the Lord was using it to bring precious souls to salvation.  We should rejoice in the proclamation of the Gospel, even though it may be given by insincere men. 

I believe these portions apply to the situation you are referring to.  During slavery, many proclaimed the truth of the Gospel and the importance of obedience, even though they were not obedient themselves as to how the Lord wanted us to treat one another.  We can surely thank the Lord for the presentation of the Gospel in spite of the prevailing conditions of the day.  How powerful is the Gospel when presented honestly.  Romans 1:16 declares that the Gospel, “is the power of God unto salvation to every one that believeth.” 

We can surely thank the Lord that slavery is no longer existing today (at least open and legal slavery).  At least in America, this change came about through the efforts of Christians, especially the Quakers. 

Historian John Stuart Mill wrote, “When Abraham Lincoln said, “If slavery is not wrong, then nothing is wrong”, he was expressing an idea peculiar to Western civilization at that time.  Although intellectuals today may condemn slavery as a historic evil of our society, what was peculiar about western society was not that it had slaves like other societies around the world, but it was the first civilization to turn against slavery and that it spent more than a century destroying slavery.” 

Economist Thomas Sowell once said in an interview, “Slavery was not confined to one set of races.  I suspect that most of the people who either were slaves or slave owners around the world were neither white nor black.  This was a universal curse of the human species.” 

As far as ancient African, or any other civilization, that worshipped God based on the knowledge they had of Him apart from the Bible, I recommend that you click on this AFTB link to read about that.

https://answersfromthebook.net/what-hope-does-the-bible-hold-out-for-those-who-died-without-having-an-opportunity-to-learn-about-the-word-of-god/

This subject is taken up there in greater detail that we can go into here.  (475.4)