The iPhone 3G came out in 2008 and can not be upgraded to run the current version on iOS. This means that some apps can't be run on it. However, a large number still can be. My 12 year old daughter uses my wife's hand me down iphone 3G and has loads of fun with apps on it.
The iPhone 3GS came out in 2009 and can currently run the latest and greatest version of iOS. This means that virtually the entire app library can be run on it, excepting those apps that require hardware which the iPhone 3GS doesn't have, such as a front facing camera. My 15 year old son uses my hand me down 3GS which works with every app he has tried so far, which is a large number of them.
I also had AT&T unlock both phones and I use them on a very cheap, voice only, pay as you go plan from T-Mobile, I just use SIM cards from T-Moblie in the unlocked phones and they work like a charm.