The speaker looks at their dog, calls him ugly, and then does something tender: they announce that since they have no child, the dog will inherit "all this moon." It's a mock will, the kind of grand gesture a person makes half as a joke and half in earnest.
The humor comes from the mismatch. Nobody can own the moon, so the bequest is both absurd and generous. The speaker has nothing material worth mentioning, or perhaps simply wants to give something beautiful. The word "ugly" doesn't sound like an insult here. It sounds like affection, the way people tease the ones they love most.
Underneath the joke there's a quiet note of loneliness and mortality. Talking about a will means thinking about death, and "having no child" admits there is no one else to pass things to. Still, the mood stays warm and gently playful. The moon seems to be shining right now, shared between a person and a dog.