Being a good Christian is not a necessity for witnessing. Of course, we are not saying that it's okay to be a sinner in rebellion against God and then go out and witness for Jesus. We are supposed to resist sin. Nevertheless, none of us are perfect, and there are times when God will ask us to witness to someone even if we aren’t walking with him very closely. Sometimes God uses this to bring us to the place of repentance by reminding us and convicting us. But, he also uses it to present the gospel to the lost because it is the gospel that is the power to save people (Rom. 1:16) even if it is preached by someone not walking properly with the Lord.
Philippians 1:15-18, “Some, to be sure, are preaching Christ even from envy and strife, but some also from good will; 16 the latter do it out of love, knowing that I am appointed for the defense of the gospel; 17 the former proclaim Christ out of selfish ambition, rather than from pure motives, thinking to cause me distress in my imprisonment. 18 What then? Only that in every way, whether in pretense or in truth, Christ is proclaimed; and in this I rejoice, yes, and I will rejoice.”