It took me two whole years to find out how to do this properly and, above all, without a jailbreak. Shortly after the one-year warranty expired, the silent switch on my iPhone 3GS broke. Repairing or replacing it did not seem worthwhile, as the device otherwise worked perfectly. So the only solution was a jailbreak and the rather annoying installation of various plugins to get the functionality I wanted.

AssistiveTouch context menu on the iPhone screen
The AssistiveTouch menu: Mute/Unmute can replace the silent switch.

Although I now use a 4S, the 3GS is still in use too. When I recently wanted to update it to the latest iOS version again, I revisited the issue and found this solution: AssistiveTouch. AssistiveTouch is one of the accessibility features included in iOS (Settings > General > Accessibility > AssistiveTouch) and displays a semi-transparent dot on the screen. Tapping this dot opens a context menu that lets you control various iPhone functions. Among other things, you can mute and unmute the sound under “Device”. This feature can also help with a broken Home button, since the context menu can trigger the Home button function too. The dot that AssistiveTouch keeps on screen can be moved anywhere, so you should be able to find a position where it does not get in the way too much.

For anyone with a broken mute switch on their iPhone who would rather avoid a jailbreak, this is certainly a practical solution!

UPDATE 27 December 2016: AssistiveTouch still works on the iPhone 6s with iOS 10.2, and the settings path described above is still correct!