3 things to check before returning the phone because of a broken camera:
1) make sure the lens is clean - really clean - not just wipe on your pants clean.
2) brace the camera completely still against a solid fixed object when taking a photo - edge of a table or side of a tree or something.
3) make sure the lighting is bright and direct.
With the 3GS, on the preview display tap the center of what you want to see in focus a couple seconds before lightly brushing the shutter button.
If none of that works even in several different daylight photos, suspect a broken autofocus or whacked lens, and try for a warranty repair/replacement.
Download the pics to a photo program on your Mac or PC for quality comparisons.
It's just a pinhole lens, so don't expect to enlarge the photo as much as when using a camera with a real lens (an ancient but full-sized 2 MP SLR will take much better photos).