This is a nice line and commonly attributed to Oscar Wilde.
But... it does not appear in any of his published work and seems different from his more commonly expressed views... such as:
Most people are other people. Their thoughts are someone else's opinions, their lives a mimicry, their passions a quotation.
~ Oscar Wilde, De Profundis, 1905
My sense is that the line was attributed to Wilde to give it more weight.
Wilde is one of the five notables (Churchill, Lincoln, Shaw, Twain, and Wilde) that have endless anonymous comments randomly attributed to them.
And once an attribution is online it seems impossible to erase.
There seems no reason to believe Wilde said the line. Let us just accept the line as a good one regardless of the source.