The song is from a comic opera called H.M.S. Pinafore(The Lass That Loved a Sailor) which contatins two acts. It first opened in London in 1878.
Captain. Fair moon, to thee I sing, Bright regent of the heavens, Say, why is everything Either at sixes or at sevens? Say, why is everything Either at sixes or at sevens? I have lived hitherto Free from breath of slander, Beloved by all my crew ? A really popular commander. But now my kindly crew rebel, My daughter to a tar is partial, Sir Joseph storms, and, sad to tell, He threatens a court martial! Fair moon, to thee I sing, Bright regent of the heavens, Say, why is everything Either at sixes or at sevens? Fair moon, to thee I sing, Bright regent of the heavens