The pope's remarks on immigration, Gaza and Ukraine have attracted considerable scrutiny in the final years of his papacy.