By sharpening them. The ship's gear would have a grindstone, and an armorer or his assistant who would take care of that.
Though it should be said that pirates did not actually fight all that often. Fighting was dangerous. Intimidate the victims into surrender (the cargo of the ship was basically never their property anyway) and treat them well so the next guys would also be willing to surrender rather than fight to the death.
Also, while movies like to portray pirates in frigates, they almost never used ships that large. And they certainly didn't fight actual warships if they had any other option.
They were in it for the money, not to commit suicide.