You do have a few issues here that you'll need to work out before you start.
I would recommend sticking with a 3.5" HD for the HD bay as you do need a means to deal with the systems temp control (SMC). Apple leveraged the HD's internal thermal sensor depending on what you currently have for a HD you may want to stick with the same make. Otherwise you'll need a special cable to access the sensor or use an external sensor.
The next issue is RPM of the drive and its heat. 3.5" drives tend to be higher RPM and have higher heat. Where the 2.5" drives tend to be the slower RPM drives. The few high RPM 2.5" drives tend to run hot so if you place it in the optical drives location it will tend to cook as the sensor within the optical drive will be missing. The other factor here is if you use a 2.5" SSD you'll need a frame to hold it in the 3.5" HD bay.
OK the last point is a bit confusing SATA technically does not have a bias. So it makes no difference which port is used as your boot drive, unlike PATA which had a master & slave which does make a difference. The other issue is if you are using a PCI drive interface then the slot's ID can be a factor. Neither are issues here.
So the bottom-line: Use a high RPM 3.5" HDD in the HD bay and either re-use the sensor cable (if you are getting the same make) or use this adapter cable: OWC In-line Digital Thermal Sensor for iMac 2009-2010 Hard Drive Upgrade. Here's the IFIXIT guide you'll need to follow: iMac Intel 21.5" EMC 2389 Hard Drive Replacement. Jump to Step14 to review the internal drives sensor cable connection.
Here is the IFIXIT guide to installing the SSD: Installing iMac Intel 21.5" EMC 2389 Dual Hard Drive
Don't forget to prep up USB thumb drive with a bootable MacOS installer. Review this guide: How to create a bootable macOS Sierra installer drive. I would stick with Sierra as the newest OS otherwise install one of the older OS's like El Capitan.