The statement in your question is meant to be applied to both the lawyer and the banker from Chekhov's short story "The Bet." The lawyer believes that life in prison is more humane than execution, and the banker disagrees. The two men set up a bet, and the lawyer stands to win a lot of money if he stays in solitary confinement for fifteen years.
While in prison, the lawyer educates himself constantly. By the end of his fifteen years, he makes a claim that he is wiser than anybody else.
"Your books have given me wisdom. All that the unresting thought of man has created in the ages is compressed into a small compass in my brain. I know that I am wiser than all of you."
Unfortunately, the only thing that his wisdom and knowledge have brought the lawyer is jaded cynicism of just about everything. He despises people and is genuinely an unhappy man.
"And I despise your books, I despise wisdom and the blessings of this world. It is all worthless, fleeting, illusory, and deceptive, like a mirage."
The lawyer then intentionally forfeits the bet five hours early, and the banker gets to keep his money. The banker is not happy about it though. The banker was prepared to kill the lawyer in order to ensure victory in the bet, but the banker didn't do it after reading the lawyer's note. Instead of being happy that he won the bet and getting to keep his money, the banker is despised with himself. He realizes what a terrible person he has become in the pursuit of wealth.
At no other time, even when he had lost heavily on the Stock Exchange, had he felt so great a contempt for himself. When he got home he lay on his bed, but his tears and emotion kept him for hours from sleeping.
The story then does a nice job of illustrating the statement in your question. Neither money nor wisdom brought either man happiness.