Why do microcontrollers have so little RAM?
There are several reasons for this.
First of all, memory takes up a lot of silicon area. This means that increasing the amount of RAM directly increases the silicon area of the chip and hence the cost. Larger silicon area has a 'double whammy' effect on price: larger chips mean less chips per wafer, especially around the edge, and larger chips means each chip is more likely to get a defect.
Second is the issue of process. RAM arrays should be optimized in different ways than logic, and it is not possible to send different parts of the same chip through different processes - the whole chip must be manufactured with the same process. There are semiconductor foundaries that are more or less dedicated to producing DRAM. Not CPUs or other logic, just straight up DRAM. DRAM requires area-efficient capacitors and very low leakage transistors. Making the capacitors requires special processing. Making low leakage transistors results in slower transistors, which is a fine trade-off for DRAM readout electronics, but would not be so good for building high performance logic. Producing DRAM on a microcontroller die would mean you would need to trade off the process optimization somehow. Large RAM arrays are also more likely to develop faults simply due to their large area, decreasing yield and increasing costs. Testing large RAM arrays is also time consuming and so including large arrays will increase testing costs. Additionally, economies of scale drive down the cost of separate RAM chips more so than more specialized microcontrollers.
Power consumption is another reason. Many embedded applications are power constrained, and as a result many microcontrollers are built so that they can be put into a very low power sleep state. To enable very low power sleep, SRAM is used due to its ability to maintain its contents with extremely low power consumption. Battery backed SRAM can hold its state for years off of a single 3V button battery. DRAM, on the other hand, cannot hold its state for more than a fraction of a second. The capacitors are so small that the handful of electrons tunnel out and into the substrate, or leak through the cell transistors. To combat this, DRAM must be continuously read out and written back. As a result, DRAM consumes significantly more power than SRAM at idle.
On the flip side, SRAM bit cells are much larger than DRAM bit cells, so if a lot of memory is required, DRAM is generally a better option. This is why it's quite common to use a small amount of SRAM (kB to MB) as on-chip cache memory coupled with a larger amount of off-chip DRAM (MB to GB).
There have been some very cool design techniques used to increase the amount of RAM available in an embedded system for low cost. Some of these are multi chip packages which contain separate dies for the processor and RAM. Other solutions involve producing pads on the top of the CPU package so a RAM chip can be stacked on top. This solution is very clever as different RAM chips can be soldered on top of the CPU depending on the required amount of memory, with no additional board-level routing required (memory busses are very wide and take up a lot of board area). Note that these systems are usually not considered to be microcontrollers.
Many very small embedded systems do not require very much RAM anyway. If you need a lot of RAM, then you're probably going to want to use a higher-end processor that has external DRAM instead of onboard SRAM.
Memory probably takes up the most silicon space, and RAM being very fast to use is volatile - and uses power constantly to keep its state. Unless you need lots of RAM, it's not useful for many other applications. If an embedded system designer needs more RAM, they merely get an external RAM chip and use peripheral memory interfaces that microcontrollers often have these days for very easy plug and play memory extension. That is the reason I see as why microcontrollers in general still have reasonable low onboard RAM, because reasonable application code and use-case scenarios normally do not need much.
When you start getting up to the larger architectures that need to run full on operating systems, then RAM becomes extremely important, however this gets out of the realm of microcontrollers and into embedded computers more like those you see in the Beaglebone and Raspberri Pi boards these days. And even at this stage, the processors are so complex and so full of features that they have no room for the amount of RAM needed for their task so external memory is pretty much required for them to operate at all.
As a personal anecdote, I recently made a small autonomous robot control board with the aim of using it for low resolution computer vision like motion detection and object tracking and following. I chose a low pin-count ARM Cortex M3 for this task and while looking at Atmel's selection of their SAM3 series processors, I indeed went for the highest RAM I could find - because in this case I did not want to buy an external RAM IC due to board space and not wanting the complexity of a high speed RAM memory bus on the PCB. In this case for my particular application, I would have very much liked to have the option of many 100's of KB more RAM if possible. I ended up only having 48KB SRAM but further designs I will get a higher pin count package and make use of the parallel data capture peripheral to rout 8-bit camera pixel data straight into an external RAM chip.
Besides the excellent points brought up in the other answers, another reason for limited RAM is the architecture of the microcontroller. For example, take the the Microchip PIC10LF320, which has only 448 bytes of program (flash) memory and 64 bytes of RAM. But it probably costs only 25ȼ (or less) in large quantities. The limited size of the PIC10 instruction word (12 bits) allows it to only address 128 bytes of RAM directly.
I am sure there are other microcontrollers out there that only have an 8-bit address bus, limiting them to 256 bytes of RAM.
But most mid-range microcontrollers (even those with 8-bit data paths), have a 16-bit address bus. A major architectural consideration for these chips is whether the chip uses Harvard or Von Neumann architecture.
Most microcontrollers uses Harvard architecture, which has separate 16-bit address spaces for program memory, RAM, and memory-mapped I/O addresses. So for these, the 16-bit address bus can access up to 64K (65,536) bytes of RAM. There is still a 64K limit placed by the architecture, and if one wants to go above that some sort of paging must be used. It is much more common to have paging for program space rather than RAM space.
Microcontrollers using Von Neumann architecture, such as the Freescale HCS08 line, have just one address space divided up between the program memory, RAM and memory-mapped I/O. In order to have a reasonable amount of program space, this limits the amount of RAM to typically 4K or 8K. Again, one can use paging to increase the available program or RAM space.