This is a bit out of my range, as I don't have this hardware, but I'll try anyway.
The light can flash in a code to indicate that it is ready to connect via Bluetooth, the code is: flash twice in succession, pause, then repeats (blink-blink-pause, blink-blink-pause). If this is what your mouse is doing, then I suspect that the Bluetooth on your iMac is randomly disconnecting.
There is apparently a bug in the macOS High Sierra 10.13.2 that's causing this, and resetting the iMac Bluetooth may resolve it.
I am assuming you can see the Bluetooth icon in the menu bar on the top right hand side.
Here is how you can see it:
Apple logo → System Preferences → Dock and Menu → Select the
Bluetooth from the sidebar and select
Show in Menu Bar.
From the OS X desktop, hold down the Shift+Option keys and then click on the Bluetooth menu item to reveal the hidden Debug menu.
Select
Reset the Bluetooth module.
Note: If using macOS Catalina, click Debug and reset the Bluetooth module.
Once the reset is complete, it may start working properly again.
Other alternatives are:
- Disable and reenable Bluetooth on the iMac
- Removing the mouse and adding it back in from the Bluetooth devices.
- Resetting devices to factory state, which will remove the device from the iMac, and reset the mouse to factory defaults. You'll need to set it up as if it was brand new. May need a wired mouse to accomplish this.
- Replace the mouse with a USB dongle mouse to get away from Bluetooth and still be wireless
- Replace the mouse with a USB wired mouse