Sting said that he wrote the song when he was drunk:
I was drunk in a hotel room in Munich, slumped on the bed with the whirling pit when this riff came into my head. I got up and starting walking round the room singing : 'Walking round the room, walking round the room'. That was all. In the cool light of morning I remembered what had happened and I wrote the riff down. But 'Walking round the room' was a stupid title so I thought of something even more stupid which was 'Walking on the moon.'
In his autobiography, Sting alludes that the song was partially inspired by an early girlfriend:
The video for the song was filmed at Kennedy Space Centre on October 23, 1979. It features the band members pantomiming to the song amidst spacecraft displays, interspersed with NASA footage. Both Sting and Andy Summers strum guitars (not bass) in the video, and Stewart Copeland strikes his drumsticks on a Saturn V moon rocket.
Deborah Anderson was my first real girlfriend...walking back from Deborah's house in those early days would eventually become a song, for being in love is to be relieved of gravity.