Call it the papercut of computer problems. Sure, problems like data loss or not being able to start up are far worse, but few things are more irritating than a mouse that moves on its own. It interrupts your work flow and decreases your productivity. The problem is known as "mouse drift" and can be caused by a variety of issues.
This is perhaps the most common source of mouse drift. If you're using a laptop, odds are your keyboard features a rubber "nub" of sorts that can be used a mouse; this nub is called a "pointing stick." If your laptop has a pointing stick and you experience mouse drift frequently, the problem is probably the pointing stick's calibration. Sometimes this is caused by wear and tear slowly bending the laptop's metal frame and throwing off the alignment. The easiest fix is turning off the pointing stick if you don't typically use it; otherwise, you'll need professional help.
Video of the Day
If you use an old ball mouse with your computer it could well be the source of your drift. These mice tend to build up dirt inside over time, which can throw off the alignment, resulting in mouse drift. Fixing this is usually easy: unplug the mouse, take out the ball and clean everything.
If you have an optical mouse—that is, one that uses lasers—drift can be caused by the surface you use your mouse on. Some surfaces, like hardwood, have nooks and crannies that can cause mouse drift. Try working with a mouse pad if you don't already.
Sometimes updating your drivers can help if your mouse uses later versions of the drivers than your operating system does. Check out the website of the company that makes your mouse for more information and up-to-date drivers for your mouse.
If your mouse is moving like a thing possessed and actually running programs in a coherent manner, odds are your problem is the result of an elaborate prank. It's possible to control a mouse remotely using a number of programs. Check your system tray and see which programs are running; if you have something called VNC running, someone's probably having fun with you. Next time it happens, write them a message asking them to identify themselves, or, if they don't respond, uninstall VNC (or password-protect it if you use it regularly.)