The Golden Rule can be considered as the most important ethical rule. It is part of almost every religion, and also part of most non-religious ethical theories.
On the other hand, all the religions and ethical theories have not much to say about the justification of the Golden Rule itself. Indeed, the justification provides in religions – messages of God, words of prophets, texts of Holy Scripts – are not relevant except for adherent of the particular religion. In non-religious ethical theories, the Golden Rule is usually not justified in terms of other principles, but introduced in an axiomatic way.
An interesting example is Kant's argumentation as given in the "Grundlegung zur Metaphysik der Sitten". Kant considers the distinction between "hypothetical imperatives" and "categorical imperatives". The "hypothetical imperative" is, in some sense, a recommendation which depends on a hypothesis about individual interests: if you want to reach A, then you have to do B. Instead a categorical imperative does not depend on any conditions: you simply have to do B.
Kant's thesis is that if there exist a categorical imperative, then this categorical imperative can be only the Golden Rule. He does not claim that a categorical imperative exists – it may appear that every imperative appears to be hypothetical. We simply may be unable to see why following this imperative is in our own interest.
… da alle, die kategorisch scheinen, doch versteckterweise hypothetisch sein mögen. …
[Damit] aber würde der sogenannte moralische Imperativ, der als solcher kategorisch und unbedingt erscheint, in der Tat nur eine pragmatische Vorschrift sein, die uns auf unseren Vorteil aufmerksam macht und uns bloß lehrt, diesen in acht zu nehmen.
… da es durch kein Beispiel, mithin empirisch auszumachen sei, ob es überall irgend einen dergleichen Imperativ gebe …
[Es ist] unausgemacht [ ], ob nicht überhaupt das, was man Pflicht nennt, ein leerer Begriff sei.
Kant, Grundlegung zur Metaphysik der Sitten
This does not mean that it is impossible to justify the Golden Rule. Instead, it is quite easy – but not as a "categorical imperative" which is superior to self-interest, but as a rational strategy for realization of the own interests.
To find optimal strategies in situations where one has to interact with other participants is studied in game theory. It is often extremely difficult to find an optimal strategy or to prove it really optimal. As usual in sciences which consider human behaviour, one can hope for strong results only for highly idealized situations or extreme simplifications. Such a particularly interesting idealization is known as the "repeated prisoners dilemma".
The original prisoners dilemma is about two prisoners blackmailed by the police to confess and turn the other in. The conditions are such that for every of the prisoners separately it is better to confess. But if above confess, they end up worse than if above reject the offer. Following the Golden Rule, they would obtain a better result – none of them would turn the other in, because nobody would like it if the other does it.
Unfortunately, this works only if above follow the Golden Rule. If only one follows the Golden Rule, and the other optimizes his own interest without caring about the other, he "ethical" prisoner ends up in much worse conditions, and the egoist wins.
While this dilemma is an important one idealized situation, there is another idealized situation which seems even more important: The repeated prisoners dilemma. In this situation, we have a lot of repetitions of the situation of the prisoners dilemma. In each round, every player has the choice to cooperate or not. He does not know what the other player will do in this round, but knows what the other player has done in the past.
In this game, a surprisingly simple strategy appears to be extremely successful: In the first round, one cooperates. Later, one does the same what the other player has done in the last round. This strategy is known as "tit for tat". This strategy is very close to the Golden Rule, because it starts with cooperation, thus, does to others what it wants for itself. It behaves non-cooperative only as a penalty for past non-cooperative behaviour of the other player.
While "tit for tat" is not always optimal, because it depends on the other strategies as well as on the particular gains and losses, and some strategies close to tit for tat may sometimes appear better, the basic idea of 1.) initial cooperation and 2.) some penalty for non-cooperation is important for success. The gain of initial cooperation is that if one plays against somebody with a similar strategy one always cooperates. The penalty for non-cooperation makes sure that one does not loose too much if playing against a non-cooperative player.
Thus, two fundamental ethical principles – the Golden Rule as a default and just penalties for non-cooperative behaviour – can be justified with game-theoretic methods as successful strategies for rational egoists.
There is a point in the egoistic justification of the Golden Rule and other ethical principles which is widely considered as problematic, if not as a decisive argument against this justification: It doesn't work always. Thus, there are situations where one can apply the justification of the Golden Rule, and other situations where one cannot.
But this is not a fault at all, but a necessity. Absolute values almost immediately lead to paradoxical results if applied outside the boundaries given by rational self-interest. Killing mosquitoes is, in particular, justified by rational self-interest, but violates the Golden Rule as applied to our relations to mosquitoes. Kant's conclusion that one should never tell a lie contradicts common moral sense as well. One can construct lots of other examples if one likes. Even that some people may accept these paradoxical conclusions does not make them more rational.
In comparison with these paradoxes the arguments against the strategic justification sound quite weak. Various moral philosophers express a feeling that the resulting justification is much too weak to explain the strength of our ethical values. But one should not forget that exaggerating the strength of the own ethical values is a reasonable egoistic strategy. Such exaggerated ethical values themself (different from the strategy to fake them) cannot be justified by rational self-interest. Thus, for those moral philosophers who apply such an exaggeration strategy the strategic justification of ethics is unacceptable.
(One can extend this argument thinking about the question if moral philosophers and other moral authorities are more or less likely to apply the exaggeration strategy. At least if one asks what people expect from moral authorities, it becomes quite obvious that exaggeration is almost a professional necessity, comparable to the ability to lie for politicians and journalists. Thus, one should not wonder that moral authorities do not accept the strategic justification of ethics.)
But this is not all. The strongest argument in favour of the strategic justification is that absolute ethical values give us no way to decide what to do in case of conflicts with other absolute values as well as with our personal interests. The strategic justification solves this conceptual problem in a simple way: One has to find the optimal strategy in the particular situation. The point is not that to do this is simple – it may be hard, even impossible in a practical situation. But it is clear what has to be done. Without the strategic justification of ethics we simply don't know what to do, what would define an argument in one or the other direction.
Thus, in the strategic justification ethical values are not absolute, they have boundaries of applicability. But this is an advantage, not a fault of the strategic justification.
The strategic justification of the Golden Rule works if the other side is able to apply some variant of a "tit for tat" strategy.
That means, it doesn't work for our relation to lower animals. We can continue to kill mosquitoes. Some higher animals are quite able to respond to our behaviour, and to show some reaction similar to "tit for tat". If we are interested in good relations with such an animal, following the Golden Rule may be a reasonable idea – but in fact not very good one, because the interests are far too different.
The strategic justification is helpful also if we have to decide how to apply the Golden Rule if there is no symmetry between different people.
The problem is that simple formulations of the Golden Rule assume symmetry between different people. As far as such a symmetry exists, the rule not to do to others what you don't like to be done to yourself works nicely. It doesn't work that nice if people are different. The professional kick-boxer would not care much if other people, just for fun, would start to beat him. Would it be in agreement with the Golden Rule if he would, just for fun, start to beat old ladies? Certainly not. It follows that it is not symmetry of behaviour which counts.
As another example, the "general" rule to kill those who have homosexual sex may be considered as formally not violating the Golden Rule. If all people would have the same sexual preferences, it would indeed not violate the Golden Rule.
But if people are different, and the strategic justification of the Golden Rule shows that it is not about formalities, in particular not about formal equality of different people, but about cooperation. That means, one should take into account the particular interest of the others. You should not do things which violate the interests of others, if you do not accept that others violate your interests in a similar way. Thus, once gays have other sexual interests, you should not force them to follow your own pattern of sexual behaviour.