It sounds like you have a fairly nasty problem. The cure may involve re-installing the OS, but there are some things you can try first.
Firstly, try the good old placebo of repairing disk permissions and repairing the disk. Do this by starting up from your software restore drive by inserting it, and restarting your computer with the C key held down. Then select Disk Utility from the "Utilities" menu.
The second thing you might want to try is Apple Hardware Test. Again, restart, but with the D key held down this time. Follow the instructions to test the hardware of your computer - this will rule out anything low level.
A final step would be to reset the SMC. To do this, shut the computer down, plug in the computer and then hold down shift, control and option on the left of the keyboard and press the power button. Then release them all at the same time. You can then start your Mac up normally.
If none of that works, it's time to re-install the operating system. Start up from your software restore drive and follow the instructions to re-install Mac OS X. There is an option to preserve your data and settings, so you won't lose anything*.
As a final note, remember that your Mac comes with 30 days of free telephone support, and a one year warranty. Applicability can be checked here with your serial number. If it's a recent purchase, don't hesitate to use either, or take it into the Genius Bar at your local Apple Store. One you convince them that something's wrong with it (and they will talk you through the tests necessary to do that), Apple are pretty good at arranging repairs and replacements.
*But a sensible reader like you always has an up-to-date backup as a matter of course, don't you? ;-)
Similar: Mouse pointer on my MacBook moves by itself.
– kenorb – 2017-09-12T15:08:50.927