Why computer monitor randomly shuts off
There are several possible reasons why a monitor would turn off randomly. Some of the reasons relate to the monitor while others relate to the computer.
Tip: If the monitor is staying on, but loosing signal (e.g. the power light goes from green to orange) this is almost always an issue with the computer and not the monitor. If the monitor power light turns off, then it is almost definitely a problem with the monitor.
One reason the monitor could shut off is because it is overheating. When a monitor overheats, it will shut off to prevent damage to the circuitry inside. Causes of overheating can be dust build-up inside the monitor, external heat or humidity where the monitor is used (especially on a hot summer day), or other blockage of the slits or holes that allow the heat to escape.
If the monitor is overheating, it is best to unplug the monitor and let it cool down fully before using again. Then, if you have canned air (anti-static, for electronics), try to blow out any dust that may be inside the monitor casing. If the room where the monitor is being used is very hot, find a way to cool it down, either by turning on a fan or the air conditioning system. Wait until the room cools down some before trying to use the monitor again. Also, if you're using an older CRT monitor, upgrading to a newer flat panel display will resolve many heat related issues in a hot environment.
Although not as common, if the power cord is loose and is not securely connected to the back of the monitor it will cause the monitor to turn off. This can cause a loss in power, resulting in the monitor shutting off. Make sure the power cord is firmly in place in the back of the monitor. It's also possible that the power connector in the monitor is going bad and not receiving adequate power from the power cord. In this case, it is typically best to replace the monitor instead of having it repaired.
Another reason the monitor could shut off is because of a malfunction in the circuitry. There could be a short in the wiring or some other failure in the circuitry, causing the picture to go black or causing the monitor to shut off completely. In this case, there may not be much you can do other than buying a new replacement monitor. Monitors are usually not economical to have repaired since the repair cost can cost more than the price of a new monitor. You could bring the monitor to a computer repair shop to have it looked at, but most likely they will also recommend replacing the monitor.
Video card or motherboard problem
If the monitor is staying on, but you loose the video signal, it's very likely an issue with the video card or motherboard in the computer. This could also be an issue with the computer or video card overheating or a defect with the video card.