It shows up on mugs, posters and greeting cards. To thine own self be true must have a pleasing sound to contented psychopaths.
I assumed it was some woefully misguided advice to embrace one's inner nature. Misguided, that is, for most of us. I haven't spent forty years wailing on my nature for nuttin.
Goes to show it's been a long time since I had any culture. It's Hamlet of course, part of a core dump of fatherly advice that's fathered centuries of repetition (emphases mine) ...
... these few precepts in thy memory
See thou character. Give thy thoughts no tongue,
Nor any unproportioned thought his act.
Be thou familiar, but by no means vulgar.
Those friends thou hast, and their adoption tried,
Grapple them to thy soul with hoops of steel;
But do not dull thy palm with entertainment
Of each new-hatch'd, unfledged comrade. Beware
Of entrance to a quarrel, but being in,
Bear't that the opposed may beware of thee.
Give every man thy ear, but few thy voice;
Take each man's censure, but reserve thy judgment.
Costly thy habit as thy purse can buy,
But not express'd in fancy; rich, not gaudy;
For the apparel oft proclaims the man,
And they in France of the best rank and station
Are of a most select and generous chief in that.
Neither a borrower nor a lender be;
For loan oft loses both itself and friend,
And borrowing dulls the edge of husbandry.
This above all: to thine ownself be true,
And it must follow, as the night the day,
Thou canst not then be false to any man.
Obviously, since it's part of a load of self-improvement advice, Polonius is not advising mere acceptance of one's nature. In the language of the time "to thine ownself be true" means "know yourself" -- don't deceive yourself. Which is the mission of middle age, so not too bad.
The corrollary that "knowing oneself" means one will be entirely trustworthy is, to put it mildly, naive. On the other hand, most of Polonius advice is more high minded that practical. I don't think Shakespeare thought he was passing on advice for the ages. He'd have been amused to find it on 21st century mugs.