The thief was saved while the Old Testament was still in effect. He is not an example of salvation under the gospel at all. But the thief was forgiven before Jesus died and therefore while the first covenant was in effect.
Jesus lived and died under the Mosaic Law. Jesus was in the fullness of time "born of a woman, born under the Law." (Gal. 4:4).Jesus clearly offered him salvation and Jesus has every authority and power to save him while on earth; Jesus had the authority to forgive sins. Adam, Noah, Moses, etc. Were never baptized and so as thief. They all lived before the death of Jesus. Jesus' teaching regarding the universal necessity of baptism for the salvation of the sinner was not given until Jesus rose from the grave and gave His Great Commission (Matt. 28:18-20; Mark 16:15-16; Luke 24:46-49). This thief lived and died before the commission: hence, the baptism commanded by Jesus had no applicability.
Another point we see that the thief was a honest and appeared to fear God, acknowledged his guilt accepted his deserved punishment, showed respect for Jesus, defended Jesus' innocence, and had some knowledge of Jesus' kingdom (Luke 23:40-42). God gave Him power to forgive sins as He was pleased. The Bible says, "But that ye may know that the son of man hath power on earth to forgive sins" (Matt. 9:6, 8).
But there was the baptism of John - Mk 1:4-5 because that was preparing people for the coming of Christ. And it was designed to be replaced by baptism into Christ and His death - cf. Ac 19:4-5
Col. 2:14 - Jesus removed the first ordinances nailing them to His cross. Until Jesus died, the Jews lived under the laws given at Mt. Sinai through Moses. When He died, those laws ceased to be in effect.
Eph. 2:13-16 - He abolished the old law through His blood shed on the cross (v13,16).
Heb. 10:9, 10; 9:16, 17 - Jesus removed the first testament and replaced it with His new covenant the gospel. It is under this New Testament that we are saved by Jesus' death. As with any will or testament, Jesus had to die to bring His testament into force. The old law was in effect until Jesus died, and then it was replaced by the New Covenant. [Cf. Gal. 3:13; Rom. 7:4]
Also we need to remember that Gods wrath will be on those you willfully disobedient to him.