Which one is grammatically correct?
- Me and her signed the contract.
- She and I signed the contract.
Could you mention the grammar rule that explains this structure, and, if possible, could you point me to some reliable references?
I, she and he are subjective pronouns. You use these when they are the subject of the sentence or the 'doer' of the action. Me, her and him are objective, used when they are the object of the sentence, or the recipient of an action.
In your example, both parties are doing the signing, so they are both subjects and you should use "She and I".
Even some native speakers get confused when there are two subjective pronouns. A common mnemonic device is to remove the other party and see how it sounds. If you recognise that "me signed it" is wrong, then "she and me" is equally incorrect.
Astralbee's answer provides the technical explanation; to summarise, English pronouns change depending on case, and so you need to analyse the position of the pronoun in the sentence to work out which form it should take. But it's worth pointing out that a lot of native speakers would say "me and her signed it" in this situation. So from a descriptivist perspective, such usage is indeed correct, at least for some accents/social situations. But this usage is often stigmatised and ridiculed, to the level where some people hypercorrect (eg saying "It doesn't matter to she and I" rather than "to her and me"). And it is especially looked down upon in formal writing. So I'd recommend for any learners to use the "traditionally correct" forms, "she and I signed it", and "it doesn't matter to her and me", which are appropriate in virtually all situations.
An oblique case does not stand in subject position. So
John and I went to talk to the doctor.
is correct and
John and me went to talk to the doctor.
is not. However, many native speakers of English (if we are honest, all but the most annoying pedants) instinctively feel that the correct form is just a tad too stiff whereas the wrong form, if perhaps to colloquial, is not entirely beyond the pale.
Moreover, many speakers who would be OK with John and me would definitely baulk at
Me and John went to talk to the doctor.
This sounds ill-educated, vulgar, low-class, what have you.
If it were just the oblique case rule, we cannot explain the obvious datum that Me and John is so much worse than John and me. Is it just because it is rude to mention yourself first?
Perhaps the me in John and me is by way of de-emphasising the speaker's part, as if to say: this is all about John, he gets all the credit (or blame!). Note that it does not work if John is replaced by a pronoun: he and me is really bad and him and me did that is not much better.
Note 1. UK speakers split the difference by using the grammatically unimpeachable myself, yourself or for an extra flourish, your good self (my good self is rather facetious).
Note 2. Native speakers can often be heard to practice hypercorrection, saying John and I even when it's in object position:
They gave John and I quite a fright.
I am talking about fluent native speakers here, who would never say:
They gave I quite a fright.
It is almost as if the phrase John and I functions as an irreducible proper name in such cases.