Howard S. answered 08/29/19
Learn from Dr. Sage to find and revise writing flaws hiding from you
I don't have a truly definite answer to your question. Let me say that honestly to start.
Having told you that, let me present some possible reasons. One reason to publish anonymously especially in Great Britain seems related to the idea of writing or authorship as an embarrassing work or career.
Another reason some say relates to trying to achieved more universality in the subject matter because knowing the author's name some readers may see the writing as more provincial and more local.
Virginia Woolf wrote that “For most of history, anonymous was a woman." Of course, as you mentioned, Hardy, a man, seemed to have no reason to publish anonymously. Alternatively, perhaps some of his viewpoints, ideas, and works put forth unique views for which he might receive readers' taunts, and perhaps he didn't want to endure those.
Again, I regret I cannot provide a definitive answer but I hope these suggestions prove helpful to you and others.