So how can you say the Catholic Church is good if its members are sinners and it had bad Popes?
Good question. The holiness of the Church does not depend on the holiness of its members, but on the Holy Spirit that animates her. The Holy Spirit is holy, thus, the Church is made holy by his indwelling.
When God created Adam, he breathed life into him. On Pentecost, the Holy Spirit descended on the apostles in the form of a strong wind and breathed life into the Church (meaning assembly. Acts 2:1-13. It should be interesting to note that the word "spirit" comes from the Latin word "spiritus" which means breath, or wind.)
So it is the Holy Spirit that gives life to the Church, not the people that make it up. Thus, the Church continues to be holy because the Holy Spirit that dwells in her makes her holy. Regardless of what the Pope, the bishops, the laity does will never make the Church less holy, or more holy.
While it is true, there were Popes who were less than exemplary, but it does not affect the holiness of the Church. (Bad popes may have acted badly, but they never changed doctrine.)
She is holy also because the Church was established by Christ, who is God, which makes her a divine institution.