This is likely a case where the original code needs to be inspected to understand the purpose of the infinite loop. If we inspect In the original code we see this:
if (!MDNS.begin("esp8266")) {
Serial.println("Error setting up MDNS responder!");
while (1) {
delay(1000);
}
}
Serial.println("mDNS responder started");
Here, it can be inferred the infinite loop is used to preserve the error message on the serial monitor. This By doing so prevents subsequent messages from scrollingannouncing the error message offDomain Name Server has started. Which may confuse the serial monitoruser.
As mentioned in other answers, infinite loops are often used to purposely reset a processor. However, this approach depend on an actively running watch dog feature. A feature that is not normally active or even supported in the Arduino development environment. Perhaps because the watch dog feature is considered an intermediate to advanced topic.