The Torah uses the terms “rasha” (an evil person) and “eid chamas” (a malicious witness). Since nobody’s perfect, how do we know what kind of “sinners” are not valid to serve as witnesses? The word “chamas” is typically used to describe someone who seizes another’s property by force. This eliminates those who rob. (A gazlan is a robber – a person who says “Stick ‘em up!” A goniff is a thief – one who breaks into someone’s house and sneaks off with the silverware.)
The reason such a person is excluded from testimony is not only because of his lack of scruples but also because he’s brazen. Unlike a goniff, a gazlan shows his face and has little fear of consequences. He cares little what will happen to him and even less about what will happen to others. How can we trust the testimony of such an individual?
Certain things are rabbinically categorized as theft; a person who is guilty of one of these is likewise disqualified from serving as a witness. People in this category include professional gamblers (who make their living off of money grudgingly handed over by others) and those who raise birds in areas where others’ birds will relocate to their coops (see Talmud Sanhedrin 24b-25a). One who lends money on interest is likewise disqualified. It is possible, however, for such people to mend their ways and be reinstated as valid witnesses (Sanhedrin 25b).
This mitzvah applies in all times and places, but it is an injunction on the court not to accept such testimony, not on the individual. In the Talmud, this mitzvah is discussed in the tractates of Sanhedrin (starting on page 24a) and Baba Kama (starting on 72b). In Shulchan Aruch, it is codified in Choshen Mishpat 34. A “rasha” not testifying is #286 of the 365 negative mitzvos in the Rambam’s Sefer HaMitzvos and #75 of the 194 negative mitzvos that can be fulfilled today as listed in the Chofetz Chaim’s Sefer HaMitzvos HaKatzar.