He came as a witness to testify concerning that light, so that through him all men might believe.
The word witness is the same word that we get our word martyr from and indeed John the Baptist would later be martyred. What a brave man he must have been. He was able, by God's grace to stand up to the wicked and absolute ruler and accuse him to his face of adultery. Because of his ascetism many see John as a hard man, but it was the quality of his personal life that made Herod sit up and take notice of him.
Notice that God's purpose in sending John was so that all men might believe. There is no sense in which John was only preaching to the elect. The gift of the Gospel is open to all sinners, whether they be Muslims, Buddhists, Hindus or atheists; whether they be hypocrites or adulterers, homosexuals or drug addicts, murderers or rapists.