The banker and lawyer make the bet for the same reason that most people make a bet. They each believe that their opinion is right and best, and they are willing to risk something to prove it.
The story starts with the narrator telling the reader that the banker had a friendly little social gathering. As with any social gathering, people get to talking about topics that can be argued about. Capital punishment comes up and a lively discussion ensues. Some people believe that it is a good thing, while other party attenders think it should never be done. Most of the opponents believed that the death penalty was immoral.
The majority of the guests, among whom were many journalists and intellectual men, disapproved of the death penalty. They considered that form of punishment out of date, immoral, and unsuitable for Christian States.
The banker flat out disagrees. He feels that the death penalty is more humane because it ends a man's life quickly instead of drawing out the process over many years.
". . . the death penalty is more moral and more humane than imprisonment for life. Capital punishment kills a man at once, but lifelong imprisonment kills him slowly."
The lawyer, on the hand, feels that both are immoral forms of punishment, but he does feel that life in prison is the better of the two choices. He feels this way because he feels that any life is better than no life at all.
"The death sentence and the life sentence are equally immoral, but if I had to choose between the death penalty and imprisonment for life, I would certainly choose the second. To live anyhow is better than not at all."
From that point, it doesn't take the banker long to tell the lawyer to put his money where his mouth is.
"I'll bet you two millions you wouldn't stay in solitary confinement for five years."
The next part I have never understood. Instead of just agreeing to the bet, the lawyer ups the ante. He agrees to stay in prison for 15 years with no extra money! He triples his incarceration time with no increase of potential reward. It makes no sense. But both men believe they are correct, and they are each willing to make a bet to prove it.