Engineer and musician's answer:
Another way you can think about it is that when you fret up the neck, you are essentially creating "fatter" strings. Imagine fretting almost all the way up to the bridge; the segment of string would start looking like a barrel. The engineering answer is that the barrel has a different area to length ratio (actually area-moment-of-inertia to length ratio).
If you can, imagine rotating a barrel end-over-end. How fast will it go? Now imagine taking all the same mass and stretching it out into a long bar. Hopefully you can see that the bar would rotate more slowly. Same mass, but different mass moments of inertia.
An idealized string is long and slender. When it starts getting short, the "barrel" nature of the string becomes more and more apparent. Vibrations of the string are a combination of 1) each string segment moving up and down, and 2) rotating back and forth. The barrel-like string (or shorter string) will rotate faster, which means a faster vibration and higher pitch.
When you fret up the neck you want a little bit of extra length to lower the pitch back down. That is what the slanted bridge does.
The b-string part on many guitar bridges is dipped down because the high e-string and the b-string are usually solid strings while the lower strings are wound. You're actually looking at two different slants because the strings are different types.
The wound strings have a lower area moment of inertia for a given diameter— there is some empty space between the different wires. This means the barrel nature of the short string takes longer to come into play as you fret up the neck. The bridge for the wound strings has a shallower slant and the bridge for the solid strings has a steeper slant.