If your iDevice is using a version of iOS lower than 5, you will need to use iTunes on your syncing computer to perform the upgrade. Use the Apple link below as a guide for the upgrade.
Also read the instructions from the section entitled "Update your device using iTunes" at the link below.
Information regarding transferring purchases from your iDevice to iTunes on your syncing computer can be found at the link below.
Follow this article to upgrade through iTunes: http://support.apple.com/kb/HT4972
It will automatically download the newest version of iOS that your iPhone supports, which, if you have an iPhone 4, is iOS 6.1.3.