Staying married is not entirely under your control, since your spouse can file for divorce even if you think your marriage is doing well. Unfortunately, the only way of being certain that you'll never get divorced is to never get married.
"Choosing the right partner" is good, but people change and grow apart and grow bored and meet other people who they might like better than their spouses. The "right partner" when you're in your twenties may not be the right partner twenty or thirty years later.