There is a bug on the iPhone speakerphone option that may cause system sounds to be very low. This includes ringer, alerts, typing sounds, etc. If you are having problems with volume, try making a call to any number, turn on the speakerphone and turn the volume to the highest using the volume up button. Hang up after doing this and your problem should be fixed.
Note: This only works when sound problems are attributed to a software bug, not when the phone has physical damage.