During Jesus' final days in Jerusalem large crowds gathered to hear Him, and His enemies were afraid a riot might break out if they attempted to arrest Him publically. They needed to arrest Him privately, but they didn't know where to find Him, since each night He slipped away to a secret location outside the city. That's why they were delighted when Judas offered to betray Jesus by leading the soldiers to Him.
Judas will always be something of a mystery to us because you're right: He had been with Jesus almost from the beginning and had all the evidence he needed to convince him that Jesus was the Savior sent from God. And yet he willingly turned against Jesus and offered to betray Him for 30 pieces of silver.
Why did he do it? Was it greed? That may have been part of it, because the Bible tells us that as treasurer of the little band of disciples Judas sometimes stole money from them. Or was it disappointment, because Jesus refused to become a king and Judas wanted power for himself? We can only speculate about this.
But the real reason was that although he was outwardly committed to Jesus, in his heart Judas remained rebellious and unbelieving. He is a sad illustration of the Bible's warning: "The heart is deceitful above all things, and desperately wicked; who can know it?" (Jeremiah 17:9, NKJV). May we all learn from his tragic example, and instead be firm in our own commitment to Jesus Christ.