In these passages is the account of Israel first turning away from God to worship the idols of the foreigners that remained in the land. The generation that knew God had died, and the new generation did not know God.
God allowed foreigners to oppress Israel. However, when Israel had suffered greatly God raised up judges for Israel to lead them out of bondage. This gave Israel peace for a time.
The Bible says that ‘God’s Holy Spirit came upon these judges.’ Because of this I assume God gave these judges knowledge of Him. With this knowledge they could be an example to Israel and turn Israel again to God.
God would test Israel by the temptations of the foreigners to see if Israel would worship their gods. God tests believers today to see if they will stay faithful to God.
We are not given judges to guide us. Rather we have the Word of God, the Bible. That is the only reliable source of Truth that we have. The Bible is essential in our lives if we want to remain obedient to God and enjoy God’s blessings.