Varvara Dobroselova and Makar Devushkin are second cousins twice-removed and live across from each other on the same street in terrible apartments. Devushkin's, for example, is merely a portioned-off section of the kitchen, and he lives with several other tenants, such as the Gorshkovs, whose son who groans in agonizing hunger almost the entire story and eventually dies. Devushkin and Dobroselova exchange letters attesting to their terrible living conditions and the former frequently squanders his money on gifts for her.
The reader progressively learns their history. Dobroselova originally lived in the country, but moved to St. Petersburg (which she hates) when her father lost his job. Her father becomes very violent and her mother severely depressed. Her father dies and they move in with Anna Fyodorovna, a landlady who was previously cruel to them but at least pretends to feel sympathy for their situation. Dobroselova is tutored by a poor student named Pokrovsky, whose drunken father occasionally visits. She eventually falls in love with Pokrovsky. She struggles to save a measly amount of money to purchase the complete works of Pushkin at the market for his birthday present, then allows his father to give the books to him instead, claiming that just knowing he received the books will be enough for her happiness. Pokrovsky falls ill soon after, and his dying wish is to see the sun and the world outside. Dobroselova obliges by opening the blinds to reveal grey clouds and dirty rain. In response Pokrovsky only shakes his head and then passes away. Dobroselova's mother dies shortly afterwards, and Dobroselova is left in the care of Anna for a time, but the abuse becomes too much and she goes to live with Fedora across the street.
Devushkin works as a lowly copyist, frequently belittled and picked on by his colleagues. His clothing is worn and dirty, and his living conditions are perhaps worse than Dobroselova's. He considers himself a rat in society. He and Dobroselova exchange letters (and occasional visits that are never detailed), and eventually they also begin to exchange books. Devushkin becomes offended when she sends him a copy of "The Overcoat", because he finds the main character is living a life similar to his own.
Dobroselova considers moving to another part of the city where she can work as a governess. Just as he is out of money and risks being evicted, Devushkin has a stroke of luck: his boss takes pity on him and gives him 100 rubles to buy new clothes. Devushkin pays off his debts and sends some to Dobroselova. She sends him 25 rubles back because she does not need it. The future looks bright for both of them because he can now start to save money and it may be possible for them to move in together.
The writer Ratazyayev, who jokes about using Devushkin as a character in one of his stories offends him, but genuinely seems to like him. Eventually Devushkin's pride is assuaged and their friendship is restored. The Gorshkovs come into money because the father's case is won in court. With the generous settlement they seem to be destined to be perfectly happy, but the father dies, leaving his family in a shambles despite the money. Soon after this, Dobroselova announces that a rich man, Mr. Bykov who had dealings with Anna Fyodorovna and Pokrovsky's father, has proposed to her. She decides to leave with him, and the last few letters attest to her slowly becoming accustomed to her new money.
She asks Devushkin to find linen for her and begins to talk about various luxuries, but leaves him alone in the end despite his improving fortunes. In the last correspondence in the story, on September 29, Devushkin begs Dobroselova to write to him. Dobroselova responds saying that "all is over" an to not forget her. The last letter is from Devushkin saying that he loves her and that he will die when he leaves her.

Question: How is Devushkin able to pay off his debt and have extra money?
Answer: Devushkin's boss feels sorry for him and give him 100 rubles just because.