First of all, we can't expect to fully understand God.
For as the heavens are higher than the earth,
so are my ways higher than your ways
and my thoughts than your thoughts. (Isa. 55:9, ESV)
John 6:37 is key to answering your question. God gave to Jesus those who came to him, but Jesus does not turn away those who come to him.
All that the Father gives me will come to me, and whoever comes to me I will never cast out. (ESV)
Those God gives to Jesus = those who decide to come to Jesus.
On the one hand, God is sovereign and all-knowing. When he created matter, he created time from beginning to end. Yet, on the other hand, he created people responsible for their decisions. See the following scriptures.
The scriptures tell us that people decide whether to follow Christ:
that whoever believes in him may have eternal lfe.
For God So Loved the World
16 “For God so loved the world, that he gave his only Son, that whoever believes in him should not perish but have eternal life. 17 For God did not send his Son into the world to condemn the world, but in order that the world might be saved through him. 18 Whoever believes in him is not condemned, but whoever does not believe is condemned already, because he has not believed in the name of the only Son of God.
(John 3:15–18, ESV)
yet you refuse to come to me that you may have life. 41
(John 5:40, ESV)
If anyone’s will is to do God’s will, he will know whether the teaching is from God or whether I am speaking on my own authority
(John 7:17, ESV)
but these are written so that you may believe that Jesus is the Christ, the Son of God, and that by believing you may have life in his name.
(John 20:31, ESV)
On the other hand, there are the verses that say God chose us: John 6:37,44; 10:29
You did not choose me, but I chose you and appointed you that you should go and bear fruit and that your fruit should abide, so that whatever you ask the Father in my name, he may give it to you.
(John 15:16, ESV)
29 For those whom he foreknew he also predestined to be conformed to the image of his Son, in order that he might be the firstborn among many brothers. 30 And those whom he predestined he also called, and those whom he called he also justified, and those whom he justified he also glorified.
(Rom. 8:29–30, ESV)
even as he chose us in him before the foundation of the world, that we should be holy and blameless before him. In love 5 he predestined us for adoption to himself as sons through Jesus Christ, according to the purpose of his will,
(Eph. 1:4–5, ESV)