Several times in the novel, Hardy compares Tess to a fly, calling up a famous quotation from Act IV: Scene 1 of Shakespeare's play King Lear:
As flies to wanton boys are we to the gods,
They kill us for their sport
The suggestion is that if there be some over-arching power in the universe it is likely to be a malevolent one, given the suffering of innocent characters like Tess. The last line of the novel reinforces this idea.