find returns the position of the string in which the substring was found, specifically, a std::string::size_type. The problem is: What position means that the substring was not found?
The answer is to return the maximum value of std::string::size_type. This value may be different on different computers, so std::string::npos represents that value.
std::string::npos is larger than the max length of a string, so that if statement basically says:
"if the position the substring was found is less than beyond the max length of the string..."