OK...it sounds like you are running Mac OS X 10.5.8 (Leopard) or 10.6.8 (Snow Leopard). It depends on which of these you are running as to how we proceed to upgrade the OS and Safari.
If you are running Leopard, then you will need to purchase a Snow Leopard upgrade CD and install it. Then you can upgrade to 10.10 Yosemite via the App Store. If you are running Snow Leopard already, then you can upgrade directly from the App Store.
In preparation for any upgrade, you should make sure you have a current backup of your entire hard drive, so you won't lose anything should something happen during the upgrade. Also, you should check which versions of other software you have such as Microsoft Office, Adobe Creative Suite, and any other important applications to ensure they will be compatible with the newer OS, as most will probably require an upgrade as well, usually at a cost.
Is there a particular reason you are looking to upgrade Safari? If it is simply for compatibility with some websites, you could try to install a third party browser such as Google Chrome or Mozilla Firefox, which would save you a lot of time and possibly money for the short term.
C