Could be a lot of things – the type of media, for example; third party software and insufficient free space are other possible causes.
Generally speaking, most users report better experiences with libraries and media stored on drives that are not their start-up disks. The media drive needs to be a fast drive (a RAID is desirable for multi-stream editing) and should have either a Thunderbolt or USB3 connection.
A 5K iMac should perform extremely well with the vast majority of kinds of FCP projects. If the media format is not unusual, if the system drive has at least 15% free space and you have the libraries stored on a good media drive, and you're still getting lagged response, change Quality to Better Performance (found in Viewer uppermost right hand drop-down). If you have any third party "cleaner", or performance-enhancing, or anti-virus software, try disabling that as well.
Good luck.
'Russ