The model year of an iMac is available at Apple menu > About This Mac.
An early 2009 iMac can be upgraded to El Capitan 10.11.6 but no later version. See: How to download macOS - Apple Support
A late 2009 through mid 2011 iMac can be upgraded to High Sierra 10.13.6 but no later version. See: How to download macOS - Apple Support
A late 2012 through late 2013 iMac can be upgraded to Catalina 10.15.7 but no later. See: How to download macOS - Apple Support
A mid 2014 and late 2014 iMac can be upgraded to the latest version of Big Sur macOS 11 but no later. See: How to download macOS - Apple Support
A late 2015 iMac can be upgraded to the latest version of Monterey macOS 12. See:How to download macOS - Apple Support
A 2017 or later iMac can be upgraded to the current version of Ventura macOS 13. See: How to upgrade to macOS Ventura - Apple Support
Be aware that if you upgrade to Catalina 10.15 or later you will also need to update any non-Apple 32-bit apps. See: https://www.macworld.com/article/232735/how-to-check-if-mac-software-is-32-or-64-bit.html
If you cannot or don't want to upgrade to recent version, install the current version of a 3rd party browser if you can and use it instead of Safari. For example: https://www.mozilla.org/en-US/firefox/109.0/system-requirements/ or https://support.google.com/chrome/a/answer/7100626?hl=en