shalom b'SHEM Yah'shua HaMashiachWhat is being discussed in all of chapter 38 ?
Chapter 38 seems to be about "can the will of man
interfere with the Patrilineal bloodline of Yah'shua".Judah is the tribe of the first-born of Israel by assignment.
Judah has three sons.
The first(Er) displeases YHvH and is struck dead.
Onan(2nd) through the sin of PRIDE refuses to offer
his seed to Er for progeny for Judah
(levitical marriage)
He directly refuses to obey YHvH's Commandments.
Judah then told Tamar to wait for Shelah grew up.Judah feared the third son would also be struck dead.
Judah failed to obey YHvH and to give Shelah to Tamar for an heir.Tamar removed her widow's garments dressed herself
as a harlot to obey YHvH and produce an heir for Judah.Thus continued the Bloodline to Yah'shua.
Which was being disrupted by haSatan and his sin of PRIDE in Onan.