Why allocate more RAM to minecraft?
Solution 1:
Allocating more RAM to Minecraft can do two things:
If the game's performance is being limited by a lack of available RAM, it will ease that possible performance bottleneck.
If the game is crashing due to Java running out of RAM (either due to bugs or due to complex constructions/mods in a world), it will postpone or completely prevent the crash from happening.
Whether allocating more RAM does either (or both) of these depends highly on what the source of the performance problem is in the first place; your particular computer's configuration and components; the size of the texture's you're using (32×32 takes 4× the RAM the default textures do, 64×64 takes 16× the default, etc.); the details of your Minecraft world(s); and what mods (if any) you have installed.
The default amount of RAM set by the Minecraft launcher is 1GB. This is usually plenty, but spikes in RAM usage or unusual circumstances can make it inadequate. If the game is normally running OK on 1GB but it's having a few issues sometimes, doubling it to 2GB should be plenty. If doubling it doesn't help, then the problem may not be solvable simply by giving the game more RAM and you may need to address the problem at the source: removing demanding mods, reducing texture pack size, solving physical heat problems, upgrading system drivers, turning off background processes, making redstone contraptions more efficient, etc.
Solution 2:
As always, @SevenSidedDie has given a most excellent, encyclopedic answer. I provide a simple anecdote.
A while back, (release 1.2 ??) I had a skeleton XP farm in vanilla Minecraft, that would crash minecraft whenever it got more than 300 skeletons trapped into it. (That number is from old memory, that's my best effort recollection.)
I bumped up memory to 4 Gig, and I've never had minecraft crash since due to excessive numbers of mobs. (It will get laggy, whenever there are more than 500 mobs around)