This sentence comes from a chapter in "The Analects", one of the ancient Chinese Confucian classics. This book was recorded and compiled by Confucius's disciples and descendants, and includes Confucius' words, deeds, and teachings. This sentence comes from a chapter of "The Analects of Confucius·Yang Huo". The original text is: "A gentleman should look at himself, and a villain should look at heaven."
However, there are different versions of this sentence, and some Slightly different translation. Usually, this sentence is interpreted to mean that a gentleman should use himself as the standard to demand himself, while a villain only pays attention to the behavior of others and demands of others. It emphasizes that a gentleman should possess the qualities of self-discipline and self-demand, rather than only focusing on the behavior of others. This idea in Confucianism emphasizes the importance of self-cultivation and self-improvement.