The two expressions are not exactly interchangeable. They may be sometimes, but even in those case, the emphasis of the sentence may change. To begin with "it's a pity" expresses negativity. If you tell someone "It's a pity you're not here", they might feel guilty, or uneasy. If you say: "I wish you were here", they just feel desired and loved. This is just a brief explanation. So much could be said for any instance in which one would use one or the other, but it's better to analyze them individually.