The title was taken from a 1961 Robert Heinlein book of the same name about a boy who comes to Earth after being raised on Mars.
This song was inspired by an encounter the band had while entering Berlin from East Germany while on their Boy tour in February 1981. At the time, East Germany and West Germany were separate countries, and Berlin was divided by the Berlin wall. U2 was sleeping in the back of their tour van when it pulled up to the crossing. The guards, understandably suspicious, made the driver open the back to see what they were smuggling, only to discover a sleepy rock band.
Bono was struck by how young the guards were, and imagined what their lives were like. He wrote the lyric based on this interaction.
"Stranger In A Strange Land" was released on U2's second album, October, which was produced by Steve Lillywhite, who was also at the controls for their debut. U2 added album cuts from October to their setlists over the years, but this song they never performed live.
Bono says this was also about the alienation the band was experiencing. "We were a rock band but we weren't living like a rock band. We were fish out of water." (U2 by U2, 2005)