It's a lot easier to eliminate pain once you understand this. I am on the Epicurean subreddit and see many people trying to avoid both pain and pleasure (out of fear that pleasure will cause long term pain), and that's simply not possible. The only way to eliminate pain as they are trying to do is to move toward pleasure.
I think that is very close to identifying the real issue we are working to combat here. That's a very widespread notion. Why love (desire!) anything or anyone when you know that you could lose them or they could die before you do and cause you all sorts of pain? This is the topic Frances Wright tackled in Chapter 10. I am not sure she is correct to argue that we would not appreciate the good without the bad, but there is a lot to think about starting with "Should we, then, to avoid the evil, forego the good?"
But there is yet a pain, which the wisest and the best of men cannot escape; that all of us, my sons, have felt, or have to feel. Do not your hearts whisper it? Do you not tell me, that in death there is yet a sting? That ere he aim at us, he may level the beloved of our soul? The father, whose tender care hath reared our infant minds — the brother, whom the same breast hath nourished, and the same roof sheltered, with whom, side by side, we have grown like two plants by a river, sucking life from the same fountain and strength from the same sun — the child whose gay prattle delights our ears, or whose opening understanding fixes our hopes — the friend of our choice, with whom we have exchanged hearts, and shared all our pains and pleasures, whose eye hath reflected the tear of sympathy, whose hand hath smoothed the couch of sickness. Ah! my sons, here indeed is a pain — a pain that cuts into the soul. There are masters that will tell you otherwise; who will tell you that it is unworthy of a man to mourn even here. But such, my sons, speak not the truth of experience or philosophy, but the subtleties of sophistry and pride. He who feels not the loss, hath never felt the possession. He who knows not the grief, hath never known the joy. See the price of a friend in the duties we render him, and the sacrifices we make to him, and which, in making, we count not sacrifices, but pleasures. We sorrow for his sorrow; we supply his wants, or, if we cannot, we share them. We follow him to exile. We close ourselves in his prison; we soothe him in sickness; we strengthen him in death: nay, if it be possible, we throw down our life for his. Oh! What a treasure is that for which we do so much! And is it forbidden to us to mourn its loss? If it be, the power is not with us to obey.
Should we, then, to avoid the evil, forego the good? Shall we shut love from our hearts, that we may not feel the pain of his departure? No; happiness forbids it. Experience forbids it. Let him who hath laid on the pyre the dearest of his soul, who hath washed the urn with the bitterest tears of grief — let him say if his heart hath ever formed the wish that it had never shrined within it him whom he now deplores. Let him say if the pleasures of the sweet communion of his former days doth not still live in his remembrance. If he love not to recall the image of the departed, the tones of his voice, the words of his discourse, the deeds of his kindness, the amiable virtues of his life. If, while he weeps the loss of his friend, he smiles not to think that he once possessed him. He who knows not friendship, knows not the purest pleasure of earth. Yet if fate deprive us of it, though we grieve, we do not sink; Philosophy is still at hand, and she upholds us with fortitude. And think, my sons, perhaps in the very evil we dread, there is a good; perhaps the very uncertainty of the tenure gives it value in our eyes; perhaps all our pleasures take their zest from the known possibility of their interruption. What were the glories of the sun, if we knew not the gloom of darkness? What the refreshing breezes of morning and evening, if we felt not the fervors of noon? Should we value the lovely-flower, if it bloomed eternally; or the luscious fruit, if it hung always on the bough? Are not the smiles of the heavens more beautiful in contrast with their frowns, and the delights of the seasons more grateful from their vicissitudes? Let us then be slow to blame nature, for perhaps in her apparent errors there is hidden a wisdom. Let us not quarrel with fate, for perhaps in our evils lie the seeds of our good. Were our body never subject to sickness, we might be insensible to the joy of health. Were our life eternal, our tranquillity might sink into inaction. Were our friendship not threatened with interruption, it might want much of its tenderness. This, then, my sons, is our duty, for this is our interest and our happiness; to seek our pleasures from the hands of the virtues, and for the pain which may befall us, to submit to it with patience, or bear up against it with fortitude. To walk, in short, through life innocently and tranquilly; and to look on death as its gentle termination, which it becomes us to meet with ready minds, neither regretting the past, nor anxious for the future.”