You may have a failing power supply (PSU), a loose connection internally, or perhaps a part that is overheating.
The first and last here are your most likely culprits. Power supplies produce less power as their lifespan increases. Eventually it will reach a point where that output is no longer sufficient to maintain power to the computer. Testing this is a relatively basic task, and the equipment needed is relatively inexpensive. If you are comfortable with opening up your PC's chassis to test the PSU feel free to do so. If you are not disagreeable then a repair shop will have a steeper price tag attached to it, but they can do it relatively quickly.
This link is to a site known as How To Geek, and it has a basic walk-through on the process. How Can Test My Computers Power Supply
You can also purchase the tester at a local PC shop, or by following this link to NewEgg for one: PC 20 24 Pin PSU ATX SATA HD Power Supply Tester Blue
It's effectiveness may be hard to believe due to its price, but it will work for your needs. More pricey models will have ports for testing connections beyond the motherboard connection (the only one you should need at this time).
The next issue I referenced is a loose connection. The reason I say this is the most unlikely scenario is that most parts and connections have some form of interlocking connection. That being said, if a connection was completely secured the mild bumps your system gets from accidentally knocking your foot against it and other mild abuses could knock that connection loose to the point it causes boot failure. A repair shop can check this quickly. If you are comfortable cracking open that computer case you can always check the integrity of your connections for free.
Finally, we come to the issue of overheating. The PSU problem is still the most probable, but overheating is not uncommon either. If you are not regularly cleaning the inside of your PC dust can accumulate that causes additional heat to the components in a variety of different ways. Dust is often the death of a machine. If you have not opened your PC on a monthly basis (I recommend more frequently), or if you are like many people and never open it at all; you may have a large amount of dust built up clogging air flow to your components. Open the chassis and vacuum out the computer with a vacuum hose. Be cautious if you have a high power vacuum and do not get any wires sucked up as this can cause damage. Do not use "Air Duster" to clean the inside of electronics. That stuff is really more of a problem than a problem solver. It can actually force dust into components in areas where it cannot be seen, blocks more airflow, and summarily produces more heat. Sometimes cleaning out your computer and improving the airflow is all that is needed to prevent overheating.
Good luck with figuring this one out, and please let me know if any of this helps you out.