How Could a Disciple Betray Jesus?

Judas was one of the twelve disciples, which meant he was essentially one of Jesus’s religious apprentices. How did a man with such a close relationship with Jesus, a man who followed Jesus and saw His miracles and good works firsthand, betray his Master?