What is the purpose and function of a pre-amp in audio sound and production?

I see a lot of items that are described as 'pre-amp' in musical instrument pedals and other items, and I'm curious how this works and what it's function is, and where in-line these devices work.

thank you in advance for any help!

In general, a preamp simply takes a small signal and makes it larger.
In a guitar pedal, a preamp gives you more gain- easier to get some crunch.
A preamp can be at any level, short of a power amplifier that actually drives the loudspeaker. All guitar amps have preamps built into them. The signal from the guitar is fairly weak and can't drive the power amplifier directly- you would hardly hear anything at all. The preamp provides the missing gain, and in a guitar amp is what you are adjusting with the volume and tone controls.
I'm going to step way out of my depth here and also add that a passive pre-amp is basically just a system to switch between inputs and pass that signal on to the amp. No gain added. Is that correct?
GAIN IS at maximum, so a passive system "attenuates" the signal to the amp providing the source (a CD player) is passing enough signal to the power amp. I love preamps for two reasons- dubbing tapes where possible- a disappearing feature unfortunately, and precise control over the volume. This adds distortion, but frankly, I don't give a damn. I wouldn't even mind occasionally having/using a loudness switch, but only for crummy recordings. 
   BTW, some guitar pedals ("stomp-boxes") are truly amazing sounding and musicians can switch them on and off without stopping playing to adjust a rack-mounted preamp. They can be wired in series on a board and the tail end goes to the amplifier(s). Some guitars have gizmos inside to get different effects but need a 9 volt battery to power the circuits.