In the end of "The Overcoat," why does the corpse float around stealing coats? Why would the author conclude a realistic story in this way?
In answer to your first question, the corpse (or ghost) of Akaky floats around stealing overcoats because, at first glance, the limited scope of his existence for a short time takes on new life because he gets a new overcoat. More than this, however, may be his spirit's desire for justice--if not for himself, then for others.
As a man of limited funds, the need for a new overcoat upset Akaky greatly. He had no money. Already he pinched each ruble he earned as tightly as possible. However, as the bitterly cold Russian weather arrived, Akaky felt the cold more acutely. When his old coat was held up to the light, the cloth was almost transparent. When he realized he had no choice, he became even more frugal. He used no candles after sunset and even went without eating at times.
For months, Akaky dreamed of the coat. He visited a shop with the tailor to select the cloth. The idea of the coat became, as the narrator writes, like a companion to him. His anticipation grew until he thought of little else.
When the material was finally bought, the tailor did a wonderful job sewing the coat. Akaky was overjoyed. His fellow clerks at the office where he worked, who had in the past been so insulting toward him, were thrilled by his good fortune. They made a great fuss, and even invited him to celebrate with them that night.
With one new overcoat, Akaky's existence, even the way he perceived himself, radically changed. He decided to join his coworkers, quite out of character for this fifty-year old man, whose only passion for so many years had been his work. Unfortunately, even as his existence had been so dramatically altered for the better, too soon tragedy struck. On his way home from the party, he was robbed of his coat. Akaky was devastated. It is as if some part of him died.
Akaky turned to the authorities for help, but all ignored him. When he uncharacteristically spoke up for himself with the last official (the Person of Consequence), the man--rather than helping Akaky--berated him simply to impress an old friend. Akaky was mortified to have been treated so harshly and collapsed.
When he got home, Akaky became very ill. In a matter of days he died, leaving no family--and no impression upon the world that he had ever lived. (And perhaps he never had truly lived.)
However, the importance of that overcoat, perhaps because it somehow validated Akaky's very existence, took on a life of its own. Almost as if to right the wrong done to him, Akaky's "corpse" started haunting the area, robbing others of their coats. Arguably, at this point the coat was no longer as important as the way he was treated by the Person of Consequence. The man, who should have helped him in an official capacity, not only did nothing, but also took advantage of his position at Akaky's expense.
There was the need for Akaky to settle a debt, but not for the coat itself. Had it been about a coat, certainly his theft of the first coat would have been sufficient. It was not until Akaky's spirit/corpse encountered the Person of Consequence and stole his coat that the thievery stopped.
It may well have been not that Akaky took that particular coat, but that his appearance to the man changed the Person of Consequence's behavior toward others. He began to use his powerful position more wisely and compassionately. At this point, Akaky had finally left his mark on the world quietly (as was his way) in a most unlikely and unexpected manner.