The occasion in the life of Moses referred to here by Jesus can be read of in Numbers 21. Israel had sinned against the Lord and judgment followed. "And the LORD sent fiery serpents among the people, and they bit the people; and much people of Israel died" (Numbers 21:6). This is just one of the many specific instances of sin recorded in the Bible so we who would come after could learn the ways of the Lord and the dangers of sin. Sin brings the deadly bite of the serpent.
When the people under conviction cried, "we have sinned", God provided a way of escape. "And the LORD said unto Moses, Make thee a fiery serpent, and set it upon a pole: and it shall come to pass, that every one that is bitten, when he looketh upon it, shall live" (Numbers 21:8).
The serpent of brass mirrored the death sentence Israel experienced by the fiery serpents, but lifted up on a pole it was an offer of life for all that were bitten. Jesus referred to this to teach Nicodemus of God's provision for eternal salvation soon to take place. Jesus had to be lifted up on a cross and experience the curse against sin, the death penalty. Though He had never sinned, the Saviour had to die. He "must" be lifted up.