Just sign into the same iCloud ID that you have with your iPhone and iPad. Then create a new library on your iMac, set it to the System Photos Library and enable iCloud Library in Photos' iCloud setting pane.
If you have sufficient space on your boot drive or volume where you have your library to store the full sized files on your iMac DO NOT enable "Optimize Mac Storage".
NOTE: if you don't have sufficient space on your boot drive but want to have the full sized images in the library you can put the library on an external drive that is formatted APFS for SSDs or OS X Extended (journaled) for HDDs and connected by cable to the iMac and run it from there.
It will take a while depending on the size of the library to populate your iMac's Photos library so keep Photos open and in the background and leave on overnight until the download is complete.
