Hi, Juan —
Thank you for your question.
Unfortunately, there was a line of Borgia and Medici Popes that were
horrible. This was the manure that fertilized the ground for the Protestant
Reformation, or rather revolt. I'm not sure of all the details, but
there were also several bad Popes in the Middle Ages. Some sold Cardinalships
to fund armies. It was not pretty.
Nevertheless, none of these Popes ever taught anything
Christ promised that he would protect His Church and the Pope from officially
teaching error. (Matthew 16:13-19, 1 Timothy 3:15)
He did not guarantee the Church would be never
be ruled by corrupt men, so regardless of these men and their lack of
personal holiness, the Church is still True.
If anything, this is a witness that the Holy Spirit is at work, keeping
the Church doctrinally pure. No other institution would have survived this
kind of internal corruption for such prolonged periods.
I hope this helps,
Under His Mercy,