Authentication Time Comparisons Are For What?

We are getting errors that seem to stem from this time comparison and were wondering what is the precise purpose of the following lines:

We have all sorts of ideas about how to avoid these errors, including just removing these lines, but obviously wouldn’t want break authentication in an unexpected way.