MIPS is a "RISC" or "load-store" architecture.
RAM used to be as fast as CPUs. So people would write programs that would use RAM as intermediate or temporary storage. Early CPUs only had a few registers due to this (i.e. 6502, Z80 - the 6502 only had 3 general purpose registers. Some CPUs like the TMS9900 actually used RAM as registers). This made the CPUs use less transistors which means they were cheaper, easier to get good yields from, easier to develop (no CAD-based chip design in the 70's...)
RAM being as fast as the CPU stopped being true around 1985 or so, and has only gotten worse.
RISC came to be partly to address this (this was before CPU cache was common or large like it is today) - by having a bunch of registers, slow RAM can be avoided a lot of time for intermediate calculation results and such.
Reducing the registers available means it has to go to slower RAM more often for this purpose.
I'm not precisely sure why 32 was selected as a "sweet spot" - other than it's 5 bits and I know MIPS opcodes have 3 5-bit fields, meaning they are easy to decode (another attribute of "RISC" philosophy) - and it's really 31 as the first register always returns 0.