I suspect you've probably either pinched the ribbon cable which attaches the trackpad to the logic board or not quite plugged the connector on the end of it back on to the logic board properly, causing it to return erratic signals to the logic board. If you didn't touch it it may have been loose to begin with and taken a knock when you replaced your hard drive.
Check out this site for instructions on getting to the trackpad cable to check it's connected properly.