There was no other way to redeem us so Jesus knew all along what was going to happen , why He was coming and since he is Love He created us...He basically would do anything to redeem His creations. So, to speak. Jesus always existed with Father God and Holy spirit through all the creation of the world etc . Holy Trinity all three of them is “one” God, more like a “family of three”of Godly Power, to describe it more or less in our human understanding