Sentence is in the passive voice
What you seem to have missed is that this is a passive-voice sentence, which causes the object to move ahead of the verb. (for example: "{S:people} {V:tell} {O:the story}" -> "{O:the story} {V:is told}")
Dummy-it can also be an object
Rather than a subject, "it" is in fact a dummy object for the verb "to recount" (meaning 1.). Substitution of an object with a dummy pronoun is rare, and only makes sense in cases where the verb object is predictable. (note that only "it" can do this; "there" cannot be used as a object-substitute)
This example is acceptable to readers because this meaning of "to recount" only ever takes a very small set of nouns as a object, and they all mean the same thing: a story. When your readers already know what the object is going to be, you don't have to explicitly state it. If you did want to restore the object, the sentence would read like this:
- A story is recounted of Thomas Carlyle that when he heard of the illness...
The main clause is in boldface. Once you see that this is a passive sentence, and have identifed the object of the main clause as "a story", then it's obvious that "of Thomas Carlyle" is just a common-or-garden subclause with no real significance, and one that can be deleted from the sentence with no grammatical problems:
- A story is recounted
of Thomas Carlyle that when he heard of the illness of ...
Of course, this leaves a dangling pronoun (who is "he"?), but that can simply be expanded to "Thomas Carlyle" without changing the structure of the sentence:
- A story is recounted that when
heThomas Carlyle heard of the illness of ...