Vanity, the state of being vain, is one of the Original "Seven Deadly Sins". At the time of the original translation of the sins into Latin, there were actually eight deadly sins, but vanity was collapsed into pride because they were deemed to be close enough to be the same.
Okay, enough history, "vain" means to be excessively or extremely interested in yourself ( your appearance, achievements, needs, status, etc.) to the exclusion of all others. You might also hear terms such as narcissistic and self-centered to describe people that care only about themselves.
So, "You're so vain." means " You only care about yourself, no one else matters.". It is quite often used when you are frustrated with someone else that always works to be on top.