This quotation comes from the Book of Ecclesiastes, chapter 1, verses 1-3:
1 The words of the Preacher, the son of David, king in Jerusalem.
2 Vanity of vanities, saith the Preacher, vanity of vanities; all is vanity.
3 What profit hath a man of all his labor which he taketh under the sun?
Loving ourselves is important. We can't love others before we first love ourselves. "Love thy neighbor as thyself" is the second of the Ten Commandments.
However, there's a big difference between vanity and self-love. Here, according to dictionary.com, is the definition of vanity: "excessive pride in one's appearance, qualities, abilities, achievements, etc.; character or quality of being vain; conceit: Failure to be elected was a great blow to his vanity."
A person who truly loves himself will love others, and will be humble aroud others. A vain person, on the other hand, will usually be boastful, arrogant. The keyword there is "excessive." All of us have a certain amount of pride in our abilities; the vain person's pride is "excessive."
The meaning of "all is vanity" is that the natural tendency of man is vanity; the wise person eschews it for humility, quiet confidence.