MOD NOTE: iPhone 3G on 4.x fw will be very slow. Since iPhone 3G only has 128MB memory, running 4.x firmware on it will give you a very slow overall UI. In fact, starting on 4.3 fw, there will be no more firmware updates for 3G. To save you the headache, it is therefore recommended that you stay on 3.1.2 or 3.1.3 fw if you are on 3G. If you are already on iOS4, read on....
So you're a 3G owner and just recently upgraded to and jailbroke iOS4.0.. cool!!! You've enabled multitasking, wallpaper, even more cool!!! Now you've got the bragging rights to say "I'm on a 3G running iOS4!!!"
You start running apps, eager to test out the new features, then all of a sudden, you notice that at each app that you open, things start to slow down.. as in really slow down to a point that it almost freezes.. Then you start to complain, "My 3G runs slow ever since I installed iOS4.. i wish i didn't upgrade.. can i downgrade back to 3.1.3?"
Well, although it said that the iOS4 was compatible to run on the 3G, it was not designed around the 3G hardware, most particularly the RAM resources. Multitasking, just like in any other operating system, requires a lot of RAM in order to be effective. The more RAM, the better. Unfortunately, the 3G only has 128MB of it and 1/3 of it is already being used by the OS's core functions.
So how do I get to enjoy it on my 3G? Here's how:
1. First of all, install SBSettings. This has a function called StatusBar FreeMem that allows you to monitor how much free RAM you have and displays it on the statusbar.
2. Secondly, get the Kill.app, which can be found on this
post and don't forget to give Flipward a karma up for this

The instructions to install this are quite simple and pretty straightforward. Once installed, you should see an icon called Refresh.
3. Third (and this is optional), install Remove Recents if you only want to see which apps are running in the background. Me, I opted not to install it because it reminds me of the Recents folder in Categories where it contains the most recent apps run. Kinda like a quick shortcut if you may.
Edit/update:
4. In addition, you might also want to add
this to your 3G fine-tuning. Credit m.o.r for the find and iSpazio for the process
After having done the above, you should be set to enjoy the 3G in all it's iOS4 glory. All you need to start doing from hereon is to remember to just tap on the Refresh app every once in a while or before you start up an app, and an occassional Respring via SBSettings.
Below is a screenshot of my 3G:
Notice the 50MB free memory? Pretty cool eh? I'll let you explore this for now coz i'm sure there'll be a lot of comments after this.. but hey, I got you started didn't I?
Enjoy
Mod Edit: Additional very cool notes courtesy of JunJunB merged from his post
Here are additional tips to help speed up your 3G running iOS4

You can read more in details
here, Im just giving the bullet points for everyones reference.
* The Double Hard Reset
the DHR consists of performing a hard reset—that is, holding the Home and Sleep/Wake buttons until your phone restarts—twice. During a hard reset, you'll see the Slide to Power Off screen, the phone will go blank, and then the Apple logo will appear when it restarts; keep the Home and Sleep buttons held down through all of this, until the Apple logo appears.
* Disable Unnecessary Features
Disable Spotlight Searches - Open Settings, then go to General -> Home Button -> Spotlight Search and uncheck anything you don't use.
* Delete Your SMS Messages
*Turn off SMS Previews- Settings -> Messages; set Show Preview to Off
* Turn off Email Previews, Threading, and Other Features: Settings -> Mail, Contacts, Calendars. Change Show to 25 Recent Messages, Preview to None, Load Remote Images to Off, Organize By Thread to Off.
* Clear Your Phone History: Phone -> Recents -> Clear.
* Turn off iPod Features: Settings -> iPod. Turn off Lyrics & Podcast Info, Sound Check.
* Start from Scratch - Restore as a New Phone, not from backup.