It is always tricky to give characters names because it is nearly impossible to think of a name that doesn't actually belong to many other people. Chekhov was probably relieved to be able to write "The Bet" without inventing names, since there are only two characters in his tale. He can call one of them "the banker" and the other "the lawyer" or "the prisoner." Chekhov probably felt that it was better to keep the story rather abstract, since it is so preposterous that he had a hard time making it seem plausible.
First he has to persuade the reader that two men would actually make such a bet. Why would any man want to keep another man a prisoner in solitary confinement for fifteen years? And why would the other man agree to such a weird proposition? Checkhov finesses this whole agreement with just a few lines of dialogue.
"It's not true! I'll bet you two million you wouldn't stay in solitary confinement for five years."
"If you mean that in earnest," said the young man, "I'll take the bet, but I would stay not five but fifteen years."
"Fifteen? Done!" cried the banker. "Gentlemen, I stake two million."
The banker has nothing to win, but he doesn't really believe he is risking two million rubles because he doesn't think anyone could stand fifteen years of isolation.
At supper he made fun of the young man, and said: "Think better of it, young man, while there is still time. To me two million is a trifle, but you are losing three or four of the best years of your life. I say three or four, because you won't stay longer. Don't forget, you unhappy man, that voluntary confinement is a great deal harder to bear than compusloory. The thought that you have the right to step out in liberty at any moment will poison your whole existence in prison."
Chekhov wanted to make it clear to the reader that the prisoner would be free to leave whenever he wanted. This makes it understandable that the prisoner could decide to forfeit the bet by walking out five hours before the deadliine. The author also wanted to make it clear that the banker would not be violating any law by keeping the lawyer a prisoner.
Chekhov himself must have realized that his story would be hard to swallow. He does not state that there was a lot of drinking being done at the big party where the bet was made, but the reader would naturally assume that at such an all-male affair there would be a lot of brandy and wine consumed. Checkhov didn't want to suggest that the banker and lawyer were drunk, because they could have called the bet off when they sobered up the next day. He himself acknowledges that the bet is incredible.
And this wild, senseless bet was carried out!
Another reason that it was unnecessary to give the characters names is that the two men are kept apart except at the beginning and the end. The focus is on the banker and his point of view. Then after the passage of fifteen years the banker lets himself into the prisoner's room. This is the first time the reader actually sees the man after fifteen years have passed. So there has been no need to distinguish the two men by names.
By not naming his characters, Checkhov gives the story more of the tone of a fable or parable, and this helps to make it seem more credible. These are not two real men but two "types" who illustrate a moral.