Leviticus 20:23

And ye shall not walk in the manners of the nation, which I cast out before you: for they committed all these things, and therefore I abhorred them.

Ye shall not walk in the manners of the nation cast out before you means Israel was forbidden to follow or adopt the practices and manners of the nations God drove out before them. The nations in view were the Canaanite nations whom God drove out of Canaan to make room for Israel. Their practices were cruel and licentious.
Those nations committed all these wrongful practices, and for that reason God abhorred them and cast them out before Israel. The prohibition was part of the call to keep God's statutes and judgments and to live differently from those nations as a people set apart and holy to Him. God had separated Israel from the other peoples and had promised to give them the land.