Corporate philanthropy is a Board of Directors level decision. Perhaps this is something Tim has championed to the Board, perhaps it came from others, perhaps Tim was one of several spearheading the effort... I applaud it, regardless of who deserves the credit.
Tim has certainly incorporated this very prominently into his leadership role at the company, which is not true of every corporate CEO (except perhaps when they can be photographed giving a check to one of their pet charities) - there are plenty who are satisfied to let someone else at the company spearhead the effort. Leadership matters, of course.
Bill and Melinda Gates' philanthropy is a personal choice, done with their personal fortune. It's not related to Microsoft - he stepped down as CEO of Microsoft in January 2000 (although he continued on as Chairman), and started the foundation that same year. I don't recall Microsoft cultivating its charitable image during the years that Gates was running the company.
While Tim Cook certainly has given of his personal wealth, I doubt it's a matter of "Bill Gates Envy." There are plenty of ways we humans can stoke our egos (or feel we're making an impact on the world). Charitable giving, taking public positions on matters of conscience, etc. tend to appeal to people who think these things are good. Others are perfectly happy to stoke their egos by spending money on themselves and trumpeting their lavish lifestyle to the rest of the world.