Israel's parliament has passed a contentious law meant to retroactively legalize thousands of West Bank settlement homes.