1. Subscribe to a quality backup software solution like Acronis or Carbonite and back up everything on your computer to the cloud. It'll cost about $100 for an annual subscription. That's the cost of saving your data.
2. Get a new hard drive (needs to be at least as large as the hard drive in your existing computer) and use the backup software to clone your old hard drive.
Once you've cloned your old hard drive, you can just swap the new cloned hard drive out with the old one that's failing, and all your software, settings, etc. will be there and function.