How to upgrade my iPhone 3G from iOS 4.2.1?

How can I upgrade my iPhone 3G from version 4.2.1 to 5.1 or more?

You don't.

The highest suppored iOS version on the iPhone 3G is 4.2.1; nothing after that will work. And given how well 5.x worked on the 3GS (trust me, it was awful), you don't want it on the 3G.

You can try to go on iTunes in your computer and upgrade it from there, and if that doesn't work, bad luck…

Apple stopped making updates for 3G available from maybe 2010. 3GS was still able to, but then in 2011, they stopped making updates available for them also.

But, well, it's okay! You can save up and buy an iPhone 5 on a contract (if you live in the US). But, save your 3G, and in 20 years, it will probably be worth quite a lot.

Actually iphone 3g stocks in ios version 4.2.1. I had own an iphone 3g before. But you can make your iphone 3g to have the experience same as the iphone 5s and same fluidity by downgrading it to ios 3.1.3 and after downgrading, jailbreak your phone and after jailbreaking, download whited0or 7. My old iphone 3g runs on whited0or 6 and now I sold my iphone 3g to my friend. Visit whited0or page on FB to learn if how to install it. It has apptimemachine or the (old appstore) which is based on ios 3 but with ios 7 experience in your old device.