The sons of Judah, Er and Onan, were wicked men, and the Bible says, the Lord killed them.
“Er, Judah’s firstborn, was wicked in the sight of the Lord, and the Lord put him to death.” (Genesis 38:7)
“What Onan did was wicked in the sight of the Lord, and he put him to death also.” (Genesis 38:10)
But what are we to understand from the statement that God killed them, since God governs all life and death? None dies but by God’s plan.
“The Lord gave, and the Lord has taken away; blessed be the name of the Lord.” (Job 1:21)
“The Lord kills and brings to life; he brings down to Sheol and raises up.” (1 Samuel 2:6)
“There is no god beside me; I kill and I make alive; I wound and I heal; and there is none that can deliver out of my hand.” (Deuteronomy 32:39)
“In his hand is the life of every living thing and the breath of all mankind.” (Job 12:10)
It seems to me that the point of saying God put Er and Onan to death is to stress that there was an unusual directness about it. God interrupted the more normal processes of life and dying (which he controls) and took them away by a more direct act.
Thus we learn that it is not meaningless to believe that all events are governed by God, and yet to pray that he intervene in extraordinary ways. Governing all does not mean governing all in the same way.