Egon von Ernau is a young man who outwardly appears to have it all. He's the only child of a wealthy banker, he's rich in his own right due to having inherited a rural estate from his deceased mother, and he is intelligent, well-educated, and reasonably good-looking. He has extraordinary skill at the piano and at billiards, and he is an outstanding rider. Yet he is not happy: having lost his mother at an early age and having been mostly ignored by his self-absorbed father, he was raised mostly by servants and learned at an early age that some of his friends valued him only for his money. This, and the lack of love and respect from his fellow human beings, has made him cynical. He has no clear purpose in life except to entertain himself, and has sampled all the supposed adventures that life in Berlin provides. He is impulsive, selfish, and sarcastic. Now, he is engaged to a woman he has never met but whom he supposes to be the same kind of gold-digger he has struggled to avoid. Accordingly, he wishes to end his life. He therefore takes a train trip to a secluded forest near Breslau, intending to shoot himself.
Before Egon succeeds in committing suicide, he is interrupted by the sound of a beautiful singing voice. The singer is obviously close enough to hear the sound of Egon's pistol, so Egon postpones his attempt at self-destruction and tracks down the singer. He arrives to see a man about his own age throw himself into a pond. Impulsively, Egon saves the stranger from drowning and hears the sad story of Gottlieb Pigglewitch's life. The man he saves is an impoverished tutor who has squandered his patrimony gambling and who was on his way to serve as a tutor to a young aristocrat but who has lost the money entrusted to him. Intrigued, Egon purchases Pigglewitch's identity on a whim, thinking that he might sample life from the perspective of a member of the professional class-- a well educated servant-- before ending his life. But what starts out as a lark turns into an educational experience.
Egon, as "Pigglewitch", arrives at Castle Osternau. There, he meets the Baron Friedrich von Osternau, his wife Emma, his cousin Albrecht who is a former cavalry officer, and Friedrich and Emma's two children. The eldest, Elise ("Lieschen") is a seventeen-year-old girl with rigid standards of morality and a habit of speaking candidly. The youngest, "Fritzchen", is a small and sickly boy. The family instinctively accepts Egon as a member of their own class: the dissipated Albrecht as a rival and the rest of the von Osternaus as a friend.
As "Pigglewitch", Egon earns the correction of both Lieschen and the second farm inspector Storting. He also gets to hear what people really think of Egon von Ernau and his decisions. He sees the devastation wrought on the innocent Bertha by Egon's sudden and unexplained disappearance, and he notices with disgust that the only person who verbally defends the von Ernaus is the hated Albrecht. Egon begins to understand how many opportunities he has missed to become a competent administrator of his own estate. He meets Bertha, who despite her beauty is just as manipulative as Egon fears.
Egon leaves Osternau before his deception is discovered or fully understood, and sets off to learn to be a competent rural aristocrat. The night he leaves, Albrecht steals a large amount of money from the Baron von Osternau. Egon is initially suspected, but the Baron who questions him is satisfied that "Pigglewitch" is not the thief. When Egon returns to Berlin he finds that Bertha is engaged to Hugo von Wangen, a young aristocrat learning the rural agricultural profession from the Baron von Osternau. Egon does not insist on marrying Bertha, and sets off to make a man of himself.
The second half of the novel takes place more than four years later. Egon has returned to his rural estate, which coincidentally is near the von Wangen estate. After a serious accident and a head injury he must finally learn to govern his impulses. He learns to his shock that Albrecht burned down the Osternau castle to cover a theft. The fire caused the death of the Baron and also young Fritzchen, leaving Emma and Lieschen to depend on the odious Albrecht. Lieschen, who has been living with the von Wangens, is about to leave to go into service and earn a living by working. This shocks Egon, who with Storting's help engineers a way to arrange for Emma to receive a financial windfall that relieves her poverty. He is eventually reunited with Lieschen who is now an adult.