Can Facebook and other iOS 5.0 apps be installed for iPhone 3G on iOS 3.1.2? I recently found my old iPhone 3G with iOS version 3.1.2. I'm planning to let my 4-year old nephew to use it. But then, I'm having a problem on installing apps like Facebook, Twitter, Instagram, etc. because these apps only support iOS 5.0 or later. 

How can I install the apps I mentioned?
Note: This answer is no longer valid.
(See @stuffe's answer on how to install apps onto old versions of iOS)

The short answer is there is no way to install an app that was created for an iOS newer then the one you are running. You should connect the device to iTunes and see if you can get it updated to the latest 4.x iOS as many games and apps that target the 4 to 8 year old demographics will certainly work on that older OS.

The longer answer (and some related discussion on this site) is that developers of more powerful apps want to use the latest APIs that are introduced every iOS, and for a developer to create an app for an older iOS version, would mean he couldn't use the newer tools. Worse, it's more work to keep using the older API so cutting them makes schedule and financial sense. For example, a resource known as ARC (Automatic Resource Counting) has made a huge difference in reducing the time and cost of app development by automatically doing things that otherwise the developer would have had to manage.
Because these necessary APIs don't exist on pervious iOS versions, there is no way to run a newer app on an older iOS. Hopefully you can use the web versions or find acceptable apps to do the things you need this device to do to continue to be of use.