I don't know if there's any footage for that specific bit, but I'm sure as far as the puppetry goes, a special, full-bodied version of Ernie was built for it, and taped in front of a blackened set, with puppeteers dressed in those black suits. More than likely, Jim was doing the head and left hand, a second puppeteer the right hand, and a third puppeteer the feet.
I'm sure with Ernie on the moon, since this was back in the days when special effects were still primitive, that a lot of it relied on trick camera angles - ala Ernie and the moon being in the foreground, while space and the earth were a backdrop in the background - if you look real closely, you can kind of tell that everything directly underneath the moon Ernie's dancing on is all part of the same prop.
As for Ernie being underwater and such, that was obviously done with blue Ernie being taped in front of a blue screen, with the puppeteers in blue; I think at some point when he's swimming into frame, you can see hints of a blue outline where the chromakey effect didn't take very well, but again, it was all primitive back in the day.