The given text is a proverb or idiom that means that problems do not matter so long as the outcome is good. It does not exploit different meanings of a word or similar-sounding words for humorous effect.
All ' s well that ends well .