Replay works by recording browser sessions that can be inspected later using time travel debugging. It's beneficial for understanding bugs as it allows developers to review the exact state and sequence of events leading to an issue.