@desden Real world (world A) Makoto was obsessed with Ai and researched all kind of projects without regards to ethics to save her (basically the powers of the specialists but in the real world, which would obviously bring an apocalypse) and after he caused the destruction of everything in the real world he created a virtual world (world B) that perfectly replicates it's past except for an agent (Yukiko) that would act on particular times to prevent Ai's death and everything that follows (such as when he needs to give that gift, which would otherwise lead him to fail the college's exam ).
The problem is that the simulation went out of control (for reasons not yet explained), and he used his infiltrated agent (Yukiko, who is unaware of it in the virtual world) to lead his virtual world self (Makoto) into absorbing the malicious code (the keys from the specialists) so he could bring all of them to outside the simulation (the real world) where they couldn't affect Ai's fate anymore (trapping virtual world Makoto in the real world, while he took his place by the side of Ai without any memories of his fuck ups and as he only needs Yukiko to lead him into the good ending without them).
The problem is that the simulation went out of control (for reasons not yet explained), and he used his infiltrated agent (Yukiko, who is unaware of it in the virtual world) to lead his virtual world self (Makoto) into absorbing the malicious code (the keys from the specialists) so he could bring all of them to outside the simulation (the real world) where they couldn't affect Ai's fate anymore (trapping virtual world Makoto in the real world, while he took his place by the side of Ai without any memories of his fuck ups and as he only needs Yukiko to lead him into the good ending without them).