I have generally assumed that Irenicus let’s you go at the start of BG2 as he is vastly more powerful than you, as are his minions at the elf tree, and the shadow thieves and could crush and recapture you anytime he wants. He wants to study you and ultimately leads you to Spellhold where he intends to enact his plan for you.
I am less convinced by the idea that you are able to genuinely escape, as Yoshimo and Bodhi’s actions make little sense (and many other things).
I recall reading other opinions on here along the lines that you are genuinely able to escape and the acts of the cowled wizards and the shadow thieves lead to the big bad changing his plan.
What do you think? I will have to do a replay in case this is spelled out somewhere - I rarely get to Spellhold before restarting these days!