This is one of the many banes of the Wintel PC user's existence. This is not to say that they don't happen to other platforms but without wishing to come on like an Microsoft hating Linux kiddie, they are a particular problem with the Windows 95/98/ME operating systems (I fail to include Windows XP because I don't know yet, not because I know it to be free of such problems; but it handles memory in much the same way as NT ans 2000 so it should be ok). On these platforms they are most often due to bad coding on the part of MS and/or the manufacturers of software used on said platform and can be fairly easily cured.
But I get ahead of myself. The problem itself is caused by Windows running out of a specific (inadequate) area in memory allocated by the operating system for various internal management purposes, and manifests itself by offering you a "This system is dangerously low on resources, would you like Windows to shut down X application" message just prior to freezing up altogether, (so that when you click on yes, probably nothing at all happens. Can you believe MS coders are at the top of their field and paid as befits that position? WHY?) Ahem, anyway... Sometimes it can be because one is running too many applications at once, especially on older boxes (Windows is said to be a multitasking OS but due to the limitations of the FAT 32 file system this is not strictly true, applications just take lots of very fast turns). The answer here is simple. Don't push your machine so hard!
Also it can be caused by bad software which allows itself to use up all the available resources before crashing without warning. Always search the internet to see if you're running an app with a commonly known problem of this type, and see if there's a patch available to cure it.
(Important note: These issues cannot be solved by just adding more RAM, it's a bad design feature within Windows 95/98/ME themselves.)
Most often the problem is facilitated and exacerbated by having lots and lots of programs running in the background. A little explanation may be required here for the less computer savvy types like myself:
When one runs an application you can see it's running because there it is in your taskbar or system tray (the little box where the clock is at, down in the bottom right hand corner of the screen). Right? Wrong! Press ctrl-alt-delete, as I'm sure you know well how to do if you've been using your Wintel PC for more than an hour or so... See that list? It's probably quite long, and all those things are programs, applications running "in the background". This is especially likely to be true if you have bought a box from a major manufacturer (Compaq is often a worst case scenario) or spend any time downloading free/shareware from the internet. A lot of these programs are likely to be MS stuff that remains semi loaded in order to facilitate faster startup times (MSN Messenger being a major culprit; you think you exited it fully huh? Think again...), or other apps you've opted, often unknowingly, to add to the Quick Launch bar within your taskbar, which sit in the same semi loaded state all the time, or features like printer icons and the like which are supposed to make the running of your computer easier and faster.
More insidiously, they can be spyware. This kind of nastiness comes from downloading those "free" apps and installing them. What happens is that a little program is also installed to send the manufacturer or it's "partners" information about your PC usage. Legally this should be stated during the installation, but often the small print is so tiny as to be non existent. These programs sit in the background ticking away, eating up memory, unbeknownst to the user.
You want rid of these, no question. The only trouble is, which to get rid of, as a few of these background apps are essential to the running of the Wintel PC. There are a couple of answers. The most simple solution is to get hold of End It All (http://home.ptd.net/~don5408/toolbox/enditall/), a useful little utility which identifies superfluous programs and can kill them all with one click of a button, while protecting stuff that's actually needed to keep the box working. You can also opt to "lock" programs you feel are necessary.
A slightly more advanced solution is to edit the PC's startup configuration using msconfig. Simply type in "msconfig" to the Run box, to be found at the bottom of the Start menu. Then go to the startup tab. There is a list with a checkbox by each item. These are the programs that are prompted to run every time the computer is booted. Now, each case is different, some programs you WANT to do this, eg. anti virus or firewall software. Figure out which is which and if in doubt, don't uncheck it. A safe rule of thumb is that the truly essential ones are "Scan registry" which checks the integrity of the registry at startup then exits itself, and "Systray" without which you can't have the clock etc. More information can be found here: http://www.pacs-portal.co.uk/startup_index.htm.
Of course, it's possible that there's something physically wrong with one or more of the machine's components, the memory (RAM), hard drive, OS or something else of the sort might be damaged. If the above measures fail to solve the problems a clean install of Windows might well be the next step, and if that fails it's possibly time to replace the memory and/or hard drive.
But let's face it, it's far more likely to be bad design on Microsoft's part...
Thanks to Albert Herring and wertperch for the advice and some technical detail. This is meant as a "beginners guide" and should be taken as such.