The moon is effectively at infinity in terms of focus. The problem is not that it can't focus, but just that the stuff is too small. Hubble has taken pictures of the moon.
The problem isn't focus, it's tracking rate. Hubble can take pictures of the moon, but not long exposures; it can't spin fast enough to follow the moon through its field of view, so it has to point where the Moon is going to be, then take the picture at the moment it passes through. https://what-if.xkcd.com/32/