From the Catholic Herald:
While still Cardinal Ratzinger, he was asked by Bavarian television in 1997 exactly that question: “Is the Holy Spirit responsible for the election of a Pope?”
His reply might surprise some: “I would not say so, in the sense that the Holy Spirit picks out the Pope… I would say that the Spirit does not exactly take control of the affair, but rather, like a good educator, as it were, leaves us much space, much freedom, without entirely abandoning us. Thus the Spirit’s role should be understood in a much more elastic sense—not that he dictates the candidate for whom one must vote. Probably the only assurance he offers is that the thing cannot be totally ruined… There are too many contrary instances of popes the Holy Spirit obviously would not have picked!”