Short Answer: Jesus' answer (in v.23 and v.24) is a re-wording and expansion of what He had just said in v.21. Actually, v.21 answered Judas' question before he even asked it, but Judas was confused (as the people around Jesus frequently were in John's Gospel) and so Jesus said it again for him in different words.
The Broad Context
Let's take a look at John's flow of thought throughout the passage that surrounds this verse. (Pay special attention to Jesus' departure, and Jesus' love.)
Chapter 13 opens with the following:
Now before the Feast of the Passover, Jesus knowing that His hour had come that He would depart out of this world to the Father, having loved His own who were in the world, He loved them to the end. -John 13:1
He then has supper with His disciples, and washes their feet as an example for them to follow after His departure (v.15). As He washes their feet He hints at His betrayal (v.10-11). The next thing we read is the following:
When Jesus had said this, He became troubled in spirit and testified and said, "Truly, truly, I say to you, that one of you will betray me." -John 13:21
He proceeds to identify His betrayer, and then says the following:
"Now is the Son of Man glorified . . . Little children, I am with you a little while longer. . . . Where I am going you cannot come. A new commandment I give to you, that you love one another, even as I have loved you, that you also love one another. By this all men will know that you are My disciples, if you have love for one another." -John 13:31-35
Jesus goes on to talk with them a bit more about His departure, and tries to comfort them. He reassures them of His Identity, promises the Spirit, and promises them that they will see each other again.
Learnings from the broad context: Jesus knows He is being betrayed and that He will soon die, and He wants to prepare His disciples for how to carry on once He is gone. In short, their charge is to love one another. This will be the mark of His disciples.
The Immediate Context
Next, we read about the following interaction between Jesus and His disciples:
[Jesus speaking:] "He who has My commandments and keeps them is the one who loves Me; and he who loves Me will be loved by My Father, and I will love him and will disclose Myself to him.” Judas (not Iscariot) said to Him, “Lord, what then has happened that You are going to disclose Yourself to us and not to the world?” Jesus answered and said to him, “If anyone loves Me, he will keep My word; and My Father will love him, and We will come to him and make Our abode with him. He who does not love Me does not keep My words; and the word which you hear is not Mine, but the Father’s who sent Me. -John 14:21-24
For clarity, I'll re-present the passage, this time diagramming Jesus' logic. (The symbol '-->' means "leads to")
Verse 21: love Jesus --> keep Jesus' commandments --> loved by Father and Son --> Jesus will disclose Himself
Verse 22: (Judas wants to know why Jesus is only disclosing Himself to them)
Verse 23: love Jesus --> keep Jesus' word --> loved by Father --> indwelling of Father and Son
Verse 24: don't love Jesus --> don't keep Jesus' words
In other words, in verse 21 Jesus is explaining how a person can come to have Jesus disclose Himself to them. In verse 22 Judas asks why Jesus is disclosing Himself to them and not to everyone else, even though Jesus has just told Him why. (People are often oblivious and confused in John's Gospel.) Jesus then proceeds to answer Judas' question by repeating what He had just said in different words. (This time He says "word" instead of "commandments" and speaks of "indwelling" instead of "disclosing Himself", etc.) He then adds a contrast.
The conversation between Jesus and Judas goes like this:
Jesus: "I will disclose Myself to whoever loves and obeys Me."
Judas: "Why are You going to disclose Yourself to us and not to everyone else?"
Jesus: "I will indwell anyone who loves and obeys Me."
Jesus: "But if anyone does not love Me they will not obey Me . . ." (The implication is that Jesus will not indwell / disclose Himself to such a person.)
So Jesus will disclose Himself to whoever loves (and thus obeys) Him. That is what leads to Him disclosing Himself to a person. So, when Judas asks why Jesus would disclose Himself to some and not to others, the answer is "because if a person loves (and thus obeys) Me I will disclose Myself to them, but if they do not love (and obey) Me I will not."