But surely the events starting at Gen 2:16, in chapters 2 and 3—command, temptation, fall, and expulsion—are puzzling because God must have known that man would fall, no? So why test him?

God commands us to be righteous, but there is no significance to a command given to robots that lack the ability to refuse. It seems to me that God preferred beings capable of refusing to mere robots; that is, surely, part of being made in God’s image. But indeed he did know what would happen in advance (many other examples of God’s foreknowledge are in the Bible; we need not marshal examples). So it must have been his will, not precisely that man would fail the test, but that failing the test was a necessary step in the movement toward the ultimate creation he wished to make. In short, one must imagine that God will prefer things better in the New Jerusalem, with wiser sinners made pure through the blood of the Lamb, than with Adam in the Garden.