Without having a whole lot to go on, this sounds to me, a bit like a hardware issue that might be indicating a bad connection or multiple bad connections which could be a result of the laptop having been dropped or otherwise mishandled.
And the mere handling of the laptop, turning it over to remove the battery, may be providing the extra bit that the connection needs to re-establish itself.
Depending on how handy you are with respect to mechanical things, the first thing you might try is examining the ribbon connection to the keyboard and trackpad. I would also take a look at the hard drive interface connection and confirm that it is firmly seated in place.
Then I would definitely run the native Check Disk utility to see what might be...