"No one who has been emasculated by crushing or cutting may enter into the assembly of the Lord" (NIV)
"He that hath been wounded in the stones, or hath his privy member cut off, shall not enter into the congregation of the Lord" (KJV)
I'll also point out that, as far as male-to-female transgenders are concerned, we don't have our "privy member cut off". I won't go into the details of MtF genital reconstruction surgery here, only to say that what was there, is still predominately there - just refashioned by the surgeon. So a literal reading needs to factor this as well.
Still, this verse seems to proscribe male-to-female, post-operative transgenders, though it does not appear to address female-to-male transgenders who obtain "privy members" and "stones". Why, then, would a transwoman be excluded, but not a transman? We return to the goose/gander argument (You'll have to apply your own standard as to which is the "goose" and which is the "gander"!) with the universal application of the text if it is to be used to condemn. Further, there are myriad transgenders - both male-to-female and female-to-male - that do not have the genital surgery, yet do live fulltime in their needed gender. Does this mean that the text, therefore, isn't addressing gender transformation?
In terms of the times in which this passage was written, it was the belief that conception took place solely within the male (the stones) and that the woman only nurtured the development of the new life. As a result, to have damaged testes or not have a functioning phallus in which to be able impregnate a woman was viewed as destroying Life. If one was unable to continue the expansion of the family, one was not "worthy" of the Temple, though they would not be exiled from the family or the tribe.
According to some scholars, this passage may also reflect an effort to maintain the purity or safety of Israel. Reportedly, many neighboring priests of different cultures would castrate themselves to demonstrate their authority or commitment.
Like Deuteronomy 22:5, if one wishes to be literal, then why are the adjacent verses to this passage also routinely ignored or no longer applicable. We no longer condemn the children of forbidden marriages or relationship, we don't consider "nocturnal emissions" as something evil, we don't follow the outline for digging latrines.
And what of Lance Armstrong? He had testicular cancer and had a testicle removed which is part of the medical treatment. Is he now to be thrown out of the church? His life is saved by doing this...it doesn't seem to be God's plan for us to be ostracized for pursuing Life. One of my father's dearest friends was a bomber pilot in World War II. On one mission, his plane was hit with flak and he was struck in one of his testicles, which was removed. Are we to exile a veteran who fought for our freedom, for our right to be free in our worship of God, from God's love? I cannot imagine that is part of God's plan either.