What version of iOS is my iPhone capable of running?
iOS 6.1.6 is the highest supported iOS version you can install on an iPhone 3GS.

Here is a handy iOS compatibility chart for iPhones (and other iOS devices).