The wicked become a ransom for the righteous, and the unfaithful for the upright. (NIV)
The wicked become a ransom for the [uncompromisingly] righteous, and the treacherous for the upright [because the wicked themselves fall into the traps and pits they have dug for the good]. (AMP)
The wicked shall be a ransom for the righteous, and the transgressor for the upright. (KJV)