Here are some suggestions that may help resolve your iMac freezing issue when using the mouse:
1. Check for software updates. Go to the Apple menu > System Preferences > Software Update and install any available updates, especially for macOS. Updates sometimes include bug fixes that can resolve performance problems.
2. Try resetting the SMC (System Management Controller). This controls things like keyboard backlighting and can sometimes help with hardware issues. To do this on an iMac, turn it off, unplug it for 15 seconds, then plug back in and turn on.
3. Check Activity Monitor (in /Applications/Utilities) to see if any apps or processes are using an excessive amount of CPU or RAM. Quit or force quit anything suspicious.
4. Test to isolate the issue. Try using a wired mouse instead of a wireless one. Or create a new user account and test if the mouse works properly when logged into the new account. This helps determine if it's a system-wide problem or related to your user profile.
5. Back up your data and try reinstalling macOS from scratch. Sometimes this resolves underlying software corruption or conflicts. You can install the OS over your existing installation without losing data.
6. Try an SMC reset on your mouse. For wireless mice this involves removing/replacing the batteries. For wired mice, unplug and replug. Also try different USB ports.
Let me know if any of those suggestions help resolve your freezing issue! Feel free to provide additional details if the problem persists.