Here's one argument for the necessity of identity. Assume a=b. a has the property of being essentially identical to a. By Leibniz's law, b also has this property. So in every world in which b exists, b is identical to a, so there's no world in which a and b are distinct.
Will that convince the anti-essentialist? No, because it relies on an essentialist assumption: that every thing x has the property of being essentially identical to x. (This is not the premise that every thing x has the property of being essentially self-identical, which the anti-essentialist may well grant.)
Can the necessity of identity be established without relying on essentialist assumptions? I don't think so. But there is a tradition of thinking it can be established solely by considerations concerning rigid designation. I thought this tradition had died and been buried, but it has arisen in a recent article in the Philosophical Quarterly by Sören Häggqvist. (Häggqvist, Sören, (2006), ‘Essentialism and Rigidity’, The Philosophical Quarterly 56:223, p275-283.)
He argues as follows. If ‘a’ and ‘b’ are rigid designators then they designate in every possible world that which they designate in the actual world. Since they designate the same thing in the actual world (let us suppose) they therefore designate the same thing in every possible world, and so ‘a=b’ is a necessary truth.
I don't think this argument works, and want to bury it for good. The argument moves from (1) ‘a’ and ‘b’ designate the same thing in the actual world and (2) in any world, both ‘a’ and ‘b’ designate what they designate in the actual world to (3) in any world ‘a’ and ‘b’ designate the same thing. But (3), pretty obviously, only follows from (1) and (2) if the necessity of identity is true, and so to rely on this move is just to beg the question. Suppose ‘a’ and ‘b’ actually co-designate but that there is a world, w, in which ‘a’ designates something distinct from ‘b’. Does it follow that one or other of ‘a’ and ‘b’ designate in w something that they do not designate in the actual world? Not if a and b are identical in the actual world but distinct in w. If a and b are merely contingently identical then of course the rigid designators ‘a’ and ‘b’ will not necessarily co-designate; in a world in which a and b are distinct then, since ‘a’ must still designate a and ‘b’ still designate ‘b’ in this world, ‘a’ and ‘b’ will designate distinct things in this world. And so to conclude that the rigid designators ‘a’ and ‘b’ necessarily co-designate because they actually do begs the question against the contingent-identity theorist.