For example, if the CPU had to continually keep checking if a key has been pressed on the keyboard or a floppy disk has been inserted in its drive, it could waste a lot of its time which could otherwise be used executing the program in memory.
A special hardware mechanism, called Interrupts, is provided whereby certain time-critical devices can interrupt the CPU's normal program sequence and divert the CPU's program counter to whichever device caused the interruption.
Only 16 interrupts are provided. The first 8 of those are reserved for system functions and the remaining 8 are provided for the use of external hardware such as the keyboard, modems, the mouse, soundcards etc.