If you haven't read Of Human Bondage, you should - this is the money shot out of context.
"Have you ever been to the Cluny, the museum? There you will see Persian carpets of the most exquisite hue and of a pattern the beautiful intricacy of which delights and amazes the eye. In them you will see the mystery and the sensual beauty of the East, the roses of Hafiz and the wine-cup of Omar; but presently you will see more. You were asking just now what was the meaning of life. Go and look at those Persian carpets, and one of these days the answer will come to you."
"You are cryptic," said Philip.
"I am drunk," answered Cronshaw.
Thinking of Cronshaw, Philip remembered the Persian rug which he had given him, telling him that it offered an answer to his question upon the meaning of life; and suddenly the answer occurred to him: he chuckled: now that he had it, it was like one of the puzzles which you worry over till you are shown the solution and then cannot imagine how it could ever have escaped you. The answer was obvious. Life had no meaning. On the earth, satellite of a star speeding through space, living things had arisen under the influence of conditions which were part of the planet's history; and as there had been a beginning of life upon it so, under the influence of other conditions, there would be an end: man, no more significant than other forms of life, had come not as the climax of creation but as a physical reaction to the environment. Philip remembered the story of the Eastern King who, desiring to know the history of man, was brought by a sage five hundred volumes; busy with affairs of state, he bade him go and condense it; in twenty years the sage returned and his history now was in no more than fifty volumes, but the King, too old then to read so many ponderous tomes, bade him go and shorten it once more; twenty years passed again and the sage, old and gray, brought a single book in which was the knowledge the King had sought; but the King lay on his death-bed, and he had no time to read even that; and then the sage gave him the history of man in a single line; it was this: he was born, he suffered, and he died. There was no meaning in life, and man by living served no end. It was immaterial whether he was born or not born, whether he lived or ceased to live. Life was insignificant and death without consequence. Philip exulted, as he had exulted in his boyhood when the weight of a belief in God was lifted from his shoulders: it seemed to him that the last burden of responsibility was taken from him; and for the first time he was utterly free. His insignificance was turned to power, and he felt himself suddenly equal with the cruel fate which had seemed to persecute him; for, if life was meaningless, the world was robbed of its cruelty. What he did or left undone did not matter. Failure was unimportant and success amounted to nothing. He was the most inconsiderate creature in that swarming mass of mankind which for a brief space occupied the surface of the earth; and he was almighty because he had wrenched from chaos the secret of its nothingness. Thoughts came tumbling over one another in Philip's eager fancy, and he took long breaths of joyous satisfaction. He felt inclined to leap and sing. He had not been so happy for months.
"Oh, life," he cried in his heart, "Oh life, where is thy sting?"
For the same uprush of fancy which had shown him with all the force of mathematical demonstration that life had no meaning, brought with it another idea; and that was why Cronshaw, he imagined, had given him the Persian rug. As the weaver elaborated his pattern for no end but the pleasure of his aesthetic sense, so might a man live his life, or if one was forced to believe that his actions were outside his choosing, so might a man look at his life, that it made a pattern. There was as little need to do this as there was use. It was merely something he did for his own pleasure. Out of the manifold events of his life, his deeds, his feelings, his thoughts, he might make a design, regular, elaborate, complicated, or beautiful; and though it might be no more than an illusion that he had the power of selection, though it might be no more than a fantastic legerdemain in which appearances were interwoven with moonbeams, that did not matter: it seemed, and so to him it was. In the vast warp of life (a river arising from no spring and flowing endlessly to no sea), with the background to his fancies that there was no meaning and that nothing was important, a man might get a personal satisfaction in selecting the various strands that worked out the pattern. There was one pattern, the most obvious, perfect, and beautiful, in which a man was born, grew to manhood, married, produced children, toiled for his bread, and died; but there were others, intricate and wonderful, in which happiness did not enter and in which success was not attempted; and in them might be discovered a more troubling grace. Some lives, and Hayward's was among them, the blind indifference of chance cut off while the design was still imperfect; and then the solace was comfortable that it did not matter; other lives, such as Cronshaw's, offered a pattern which was difficult to follow, the point of view had to be shifted and old standards had to be altered before one could understand that such a life was its own justification. Philip thought that in throwing over the desire for happiness he was casting aside the last of his illusions. His life had seemed horrible when it was measured by its happiness, but now he seemed to gather strength as he realised that it might be measured by something else. Happiness mattered as little as pain. They came in, both of them, as all the other details of his life came in, to the elaboration of the design. He seemed for an instant to stand above the accidents of his existence, and he felt that they could not affect him again as they had done before. Whatever happened to him now would be one more motive to add to the complexity of the pattern, and when the end approached he would rejoice in its completion. It would be a work of art, and it would be none the less beautiful because he alone knew of its existence, and with his death it would at once cease to be.
[Philip leaves the art world, goes to medical school, thinks his low-born girlfriend is pregnant, decides to sacrifice his life and marry her, then she finds out she's not pregnant after all]
An extraordinary sensation filled him. He had felt certain that Sally's suspicion was well-founded; it had never occurred to him for an instant that there was a possibility of error. All his plans were suddenly overthrown, and the existence, so elaborately pictured, was no more than a dream which would never be realised. He was free once more. Free! He need give up none of his projects, and life still was in his hands for him to do what he liked with. He felt no exhilaration, but only dismay. His heart sank. The future stretched out before him in desolate emptiness. It was as though he had sailed for many years over a great waste of waters, with peril and privation, and at last had come upon a fair haven, but as he was about to enter, some contrary wind had arisen and drove him out again into the open sea; and because he had let his mind dwell on these soft meads and pleasant woods of the land, the vast deserts of the ocean filled him with anguish. He could not confront again the loneliness and the tempest. Sally looked at him with her clear eyes.
"Aren't you glad?" she asked again. "I thought you'd be as pleased as
He met her gaze haggardly. "I'm not sure," he muttered.
"You are funny. Most men would."
He realised that he had deceived himself; it was no self-sacrifice that had driven him to think of marrying, but the desire for a wife and a home and love; and now that it all seemed to slip through his fingers he was seized with despair. He wanted all that more than anything in the world. What did he care for Spain and its cities, Cordova, Toledo, Leon; what to him were the pagodas of Burmah and the lagoons of South Sea Islands? America was here and now. It seemed to him that all his life he had followed the ideals that other people, by their words or their writings, had instilled into him, and never the desires of his own heart. Always his course had been swayed by what he thought he should do and never by what he wanted with his whole soul to do. He put all that aside now with a gesture of impatience. He had lived always in the future, and the present always, always had slipped through his fingers. His ideals? He thought of his desire to make a design, intricate and beautiful, out of the myriad, meaningless facts of life: had he not seen also that the simplest pattern, that in which a man was born, worked, married, had children, and died, was likewise the most perfect? It might be that to surrender to happiness was to accept defeat, but it was a defeat better than many victories.
[Bolded emphasis mine.]
I did not realize for many years that Of Human Bondage is a tragedy.