Hello and welcome.
A iMac (27-inch, Late 2013) supports up to macOS 10.15 Catalina. Is there a specific reason you only want to go up to OS X 10.10.5 Yosemite?
As always, it is highly recommended that you have a current Time Machine or other backup of your data, especially when upgrading the operating system.
When making a large upgrade of OS X/macOS, many of the the third-party applications you have will also require updating/upgrading to be compatible, and many of them will probably be paid upgrades.
Since you’re running Mountain Lion 10.8, you will need to upgrade to El Capitan 10.11 first, if you want to go to macOS 10.12 or later.
How to get old versions of macOS
Hope that helps,
C