Then Judah identified them and said, "She is more righteous than I, since I did not give her to my son Shelah."
This is not a speech delivered in the context of biblical morality. In fact, in this one short chapter, Judah lives more immorally and with impunity than any other short section of scripture describes. He is in contrast to his youngest brother, Joseph, who was presented with occasion to sin and fled from it. Judah's family is very immoral. From his sons, to himself, sexual sin prevails upon his household.
In this episode, Judah manages to get the widow of his immoral sons, Er and Onan, pregnant. He assumes she is a prostitute (which makes the situation even worse). She must deceive him to fulfill levirate marriage law, which required that the unmarried brother of a husband who died take a widow for his wife. When Judah refuses to give Tamar his youngest son in marriage, she resorts to deception to obtain a child. This is certainly a soap opera, no doubt.
It is in the context of lies, immorality, sexual promiscuity and prostitution that Judah makes this pronouncement that Tamer "is more righteous than I". That is certainly a vague and valueless statement given the circumstances. It does not ring with even a hint of holiness. It is the inevitable consequence of defining righteousness down in a deviant culture.
More and more, my culture looks like Judah's home. I find that immorality and sexual promiscuity have become the norm even in homes within the church. I am witnessing the pornification of American culture to the point that sexual deviancy is the joke in the average sitcom on television. Righteousness will become so relative as to be in non-existence, just as it was in Judah's household.