I'm just really curious. I've always wondered what the 9 volt battery in the back of a guitar does.

Sorry! Just wondering.
I am by no means a guru at this but they are for active basses. It means Either the pickups will have a boosting sound, or there will be an EQ on your bass for quick adjustments to your tone or both.
mine basically completely runs on it. I have an Ibanz SR506 and when the battery starts to die (which takes a long time, don't worry) the bass will start to sound like its dying and sound like crap, then pop in 1 new 9V and it's back sounding like you just bought it yesterday!
If your bass has a battery in the back, it means that it is an active bass. Active basses use a 9 Volt battery to help boost the tone and quality of your sound. It is completely opinion on wether or not active basses are better than passive (doesn't use a battery) basses. You won't need to replace the battery for about a year, so thats $2 a year out of your pocket, not much.
My Opinion, it's worth it, you can customize your tone with treble,mid,bass however you want. It really helps you get the exact sound you want.