What is the chance that jailbreaking my iPhone will brick the phone? How does it actually work? Does it change just the firmware on the main filesystem? Does it touch the bootloader?

I'm trying to figure out what's probability of


iPhone jailbreak bricking the phone
Apple's update bricking the jailbroken iPhone (In the line with those questions, does Apple's update simply overwrites the flash partition with the new one and then applies the backed up data?)




Edit: should probably mention it's a 3GS with 4.1 firmware.
Jailbreaking utilizes an exploit in the OS (or in the latest cast, the boot ROM), and injects the payload onto the phone, which is usually a loader to install Cydia, or Cydia itself.  Cydia is the source for applications not in the App Store, and once this is loaded, other software can be installed which could modify system files.  One such case is Winterboard, which allows you to customize aspects of the UI.

With regards to question 1:

It depends on what happens during the jailbreak.  If, for example, you're running the exploit to jailbreak the phone and the battery dies (or the software malfunctions), there's a chance you'll brick it.  It's hard to pin a percentage on it.

With regards to question 2:

Since Apple is expecting their software to be running on the phone, it may do some things that could brick the phone.  Again, it definitely varies on what has been changed, how the jailbreak was performed, etc.  Personally if Apple comes out with an iOS update, I'm not going to just allow it to run.  If I want it, first thing I'd do is restore the original firmware via iTunes.