victor1244 wrote:I was just giving some background as to my hard drive problem.
From the information you've given so far, I don't see a hard drive
problem. All I see is an error message you've reported, when you try to install Ubuntu onto a disk - that is probably because the disk already has an Ubuntu partition filling it, hence leaving no room for you to install Ubuntu onto the disk again without extra steps, as there is no unused space. If my guess about what you mean is correct, then that isn't a hard drive problem.
victor1244 wrote:How do I restore my drive to be like it just came from the factory?
The exact answer to your question, is that the above objective is impossible for you - e.g. the power-on count (and others) will have incremented and you can't set that back to zero(-ish) (i.e. factory-fresh) yourself. With respect, I don't think you meant what you wrote, as you probably didn't realise everything that objective would mean.
If you meant to ask how to erase the user data area, then you can follow the previous suggestions about secure erase. However as I explained, from your Ubuntu error message, you don't need to use that (somewhat complex) secure erase procedure, which has some extra complications in popular PC configurations. You could zerofill the drive if you
really want to erase the previous contents of the disk, but it depends whether that approach (e.g. using a bootable Linux Live CD/DVD/USB to then zerofill the drive) is easier for you or not. I don't know your skills/experience/availability of Live Linux image etc.
Unless you have better evidence than the Ubuntu error message, for wanting to "restore my drive to be like it just came from the factory", then I politely suggest that that is an unnecessarily difficult objective for you, to simply be able to install Ubuntu again (which seems to be what you were trying to do, although you've stated a different objective of erasing everything from the disk, for reasons which you haven't explained).
If you explain exactly
why you want to put the disk
close to the state "like it just came from the factory", then that would be helpful for us to understand what you are trying to achieve (and please don't say that you want to erase the disk - tell us what you plan to do
after that

). Or feel free to try the secure erase approach which others have recommended, but you may struggle - many people do, especially on laptops.