The explanation of origination and flowing of destiny is explained here. Let’s see how.
197. Rabbi Amorai sat and expounded: Why was Tamar worthy of being the mother of Peretz and Zerach? It was because her name was Tamar. Tamar was [also] the sister of Amnon. She was therefore made for this. Why were they called Peretz and Zerach? Peretz was named after the moon. The moon breaks out (paratz) at times, and will be built up in the future. Zerach was named after the sun, which always shines (zarach) in the same manner. But Peretz was the first-born. Is then the sun not greater than the moon? This is no difficulty, as it is written (Genesis 38:28), "One put out a hand," [indicating that Zerach's hand emerged before Peretz was born]. It is then written (Genesis 38:30), "This his brother, upon whose hand was the scarlet thread, emerged, and he was named Zerach." [Zerach] was supposed to have been the first-born. But God saw that Solomon would descend [from Peretz], and He had such great joy that He made [Zerach] return.
Commentary: Things get turned around in Torah. Tamar deceives Judah her father inlaw into fathering these children Peretz and Zerach. Yet she is considered to be worthy of being their mother despite the deception. Judah by his word had promised Tamar at first that his son Onan would give her a child in lieu of Er his first born who was wicked and slain by the LORD. Onan didn’t want to do this so he too was slain by the LORD. Then Tamar is promised that his third son Shelah would give her a son. This did not happen either. Tamar therefore had to deceive Judah in order to make sure his word was true and that she did conceive twins is further proof of the efficacy of Judah’s word since both children represented respectively Er and Onan who were slain by the LORD. The confusion over the one Zerach putting out his hand ahead of Peretz shows that both are considered to be first born even though Peretz is the one who emerged fully first. Okay so much for this Torah stuff. Now what can we make of this internally?
Our thoughts move in response to our desires. Many times we do not think out the consequences of those desires and therefore end up producing something that we could not foretell would be happening. Judah’s word has made a very complicated mess of things and except for Tamar his word would never have be fulfilled. Events will fulfill themselves in spite of what may seem to be the random nature of the universe. In the sense of the above verse the end justifies the means here. Solomon is the result of this play confusion. What is Solomon? Solomon is Wisdom of course. Then we can see that the result of the outworking of this divine plan was to bring Wisdom into the world. What this is saying in terms of the first born is that sometimes we’ll have a thought and then suddenly pull back from that thought at the same time remembering to pursue this thought at another time. We pull back from our initial inspiration because what comes next is of even greater importance. The trick is in recognizing what to expand upon and what to leave go of. That discrimination is a life long balancing act that ever more relies upon intuition as the deep inner discernment of what comes next. In a sense we must learn to anticipate thought as it is coming through. Then we are able to see the entire thread in a single conceptual breakthrough.