Most of the time, the sensor is good, but it seized in the hole and it cannot be remove without destroying it. In order to remove the hub bearing, you have to remove the abs sensor.
You don't need to take the sensor off for that job by the way . Just have to remove the ring where the abs goes on the new hub and put it back when the part is in place . I did both of my front wheel bearing . That's a nasty noise