Hosmer-Lemeshow test is a (summary level) goodness of fit test. Not a residual test.
Here the assumption is the model is perfect.
So if the model is perfect then the chisquare value ( obs value - actual value =0) become zero. and P value become 1.
So higher the P value ( smaller the chisquare value) is better.