Deuteronomy 9:5

Not for thy righteousness, or for the uprightness of thine heart, dost thou go to possess their land: but for the wickedness of these nations the LORD thy God doth drive them out from before thee, and that he may perform the word which the LORD sware unto thy fathers, Abraham, Isaac, and Jacob.

When clear light has been given showing what should be done and what should not be done, departure from that light does not immediately remove all prosperity. If exalting principles are not woven into the work yet outward success still continues, that continuance is not to be credited to personal righteousness or uprightness of heart. It remains only because of great divine mercy extended to undeserving recipients. The reason for that forbearance is that the divine name should not be dishonored before the world.