The Marriage Scenerio
The Bible says Joseph was a just man. He was planning on divorcing Mary when he found out she was pregnant (Matthew 1:19). Betrothal is a legal union. A divorce would be legal because she was thought to have committed adultery. By the law, Joseph had the right to divorce her. Divorce is allowed in two situations, adultery (Matthew 5:32) and abandonment (1 Corinthians 7:15).
Israel was the wife of God and he divorced her, because of her adultery with idols (Jeremiah 3:8). Idolatry is not just worshiping false statues of gods, but money can be an idol. It’s whatever you have fully given your heart to, that has taken the place of God.
God dissolved his union with Israel after they were in covenant with him. If you abandon God or have idolatry in your life after you are saved then God has legal grounds to dissolve his union with you.
The Book of Life and The IF Statements
Revelation 20:15, Anyone whose name was not found written in the book of life was thrown into the lake of fire. To enter heaven, your name needs to be written in the book of life.
Psalm 69:28, May they be blotted out of the book of life and not be listed with the righteous. This says a name can be removed from the book of life. For a name to be removed, it means it must have been written in the book. This verse evidences that salvation can be lost. You can find similar statements in Revelation 3:5 & Revelation 22:19.
Colossians 1:22-23. He has reconciled you by Christ’s physical body through death to present you holy in his sight, without blemish and free from accusation, IF you CONTINUE in your faith, established AND firm, AND do not move from the hope held out in the gospel. See also (Hebrews 3:14, & Revelation 2:10). If God did not spare the Jewish nation when they walked away from him, due to their lack of trust in him and their adultery, then why would he spare members of the church who do the same thing (Romans 11:20-24)?