Most commonly traced to the Yuan zaju 《
琵琶记》 and widely circulated in late-imperial verse:
我本将心向明月,
奈何明月照沟渠 (I turned my heart toward the bright moon — but alas the bright moon shines into the ditch). The image: you offer your heart to something pure and high (the moon); it ignores you and shines on a gutter instead. Exact original is disputed (traditionally attributed to
高明 in 《
琵琶记》; also found in Yuan-era qu poetry) but the couplet has been proverbial since the Ming.