What is it that forms the basis of your life? What is the thing, desire, or idea that is at the bottom of everything for you? What is it that drives your decision making? "To Live is Christ and to die is gain" is Paul's way of answering that question.
The reason Paul is able to honestly declare "To live is Christ and to die is gain," is rooted in two ideas:
1) The Assurance of Deliverance. Deliverance here can mean rescue from harm, or it can mean preservation. What Paul is getting at is the outcome doesn’t dictate his deliverance. It doesn’t matter whether he gets out of prison or dies for his faith—either way he is delivered. This assurance spills over into the second thing—Paul's hope.
2) An Eager Hope that Paul would honor Christ in his body, whether by life or by death. His hope isn’t on his 401k, his kid’s sports team, his marriage or singleness, his wealth or his health. Simply this: in whatever comes my way, may Christ be honored in my life or my death.
These two ideas enable Paul to say honestly, "to live is Christ and to die is gain." If you and I were able to say that along with Paul, what an incredible amount of freedom we would have, because what can really happen to a person whose soul aim is to honor Christ in life or death? Nothing. Nothing can happen that can rob you of Jesus.
But we do not stumble into being the types of people who can say "to live is Christ and to die is gain." You can't treasure money, sex, and power and one day wake up finding your soul fulfilled in the person of Christ. The bottom of our joy is constructed, manicured, and cultivated. So to become this type of person we must first come to Jesus. Continually and repeatedly, we must come to Jesus. Living in pursuit of our own glory and pleasure comes naturally and it is only in the presence of Jesus that our appetites change. Second, we must cultivate an awareness of Jesus presence in the everyday stuff of life. You will never honestly say “to live is Christ” if you do not learn to enjoy the presence of Christ. This is prayer's primary aim. If we stop at petition, then we miss the sweetness of prayer because at it's very core, prayer is a posture of the heart before God that expresses our longing to know Him and experience his presence.