Calling yield() or delay() - why would you use that in an infinite loop?

[edited out of How to delay using millis() - #36 and created this new discussion so that we don't hijack the original thread]

Your sketch works well; however, the yield() (is it a function or keyword?) brings the control back to case ALARM which I have verified by placing print() command as follows.

case ALARM: 
    Serial.println("Smoke Detected");
    yield(); 
    break;
Smoke Detected
Smoke Detected
Smoke Detected
Smoke Detected
Smoke Detected

I am not much familiar with yield()? Google has not helped much. I will try ChatGPT.