Never attempt to teach a pig to sing; it wastes your time and annoys the pig.
Some efforts are doomed not because you lack skill, but because the other party cannot or will not change, and pushing anyway costs both sides. The pig can't sing, and being nagged to do so only irritates it, while you lose hours you won't get back. The joke carries a practical point: before spending energy on persuading or teaching someone, ask whether they are able and willing to learn.
The line is usually credited to Robert Heinlein, whose fiction often featured blunt, practical characters who prized competence and self-reliance. It is commonly linked to his character Lazarus Long, though similar sayings circulate as folk wisdom, so the exact origin is a little blurry. It sits in a long tradition of skeptical common sense, close to the old advice about not casting pearls before swine, which also warns against wasting something valuable on those who won't receive it.
A modern example: a colleague has brushed off every explanation of a new way of working, and you've spent three lunches debating it. You could say your piece once, kindly, and then stop, putting your patience into teammates who are curious. That isn't contempt for anyone. It is simply choosing where your effort can actually do some good.