My CPU comes off with the cooler every time. Now, I just try to reach under the cooler and undo the latch first and intentionally remove the whole thing. Then, I grab the corners of the CPU circuit board (not the pins) and turn it until it comes free from the cooler. It helps to have run the CPU up to high temps just before turning off the computer. Softens up the thermal paste. I immediately put the CPU back into the socket and latch it, even before cleaning off the old paste. That's the safest place for it; no chance of dropping it and bending pins!
If the pins are not bent enough to interfere with reinstalling the CPU, I would just leave them alone. If they are seriously bent, you can straighten them. Plenty of YouTube videos showing methods. I wouldn't straighten them unless necessary because if you break one off, you have to buy a new CPU.