You are a gentleman and a scholar most likely has its roots in 18th-century England. Scholarly pursuits and noble demeanour were valued during this time as key traits in men.
This phrase gained notoriety in the contemporary era when it was used in “The Catcher in the Rye” by J.D. Salinger. This is what the main character Holden tells Ackley, his roommate. I gave him a goddamn shoulder pat while I was still seated on the floor. I told the Ackley kid, “You’re a prince.” “You realise that? Really, you are a prince. You’re a scholar and a gentleman, young man.