Cook stressed the importance of technology, but cautioned the class of 2017 against losing sight of their humanity.

Tim Cook urged Massachusetts Institute of Technology's class of 2017 to use their minds, hands, and heart to build something bigger than themselves, and to never lose sight of their humanity. Apple's CEO told the graduates on Friday morning that they must keep their morals at the center of what they do.

"Measure your impact on humanity not in likes but in the lives you touch, not in popularity but the people you serve," Cook said during his commencement speech. "I found my life got bigger when I stopped caring about what people thought of me."

Cook explained that when he was younger, he struggled to find purpose in his life. He searched for it in graduate school at Duke University, meditation, religion, and the writings of philosophers. He also joked about a "moment of youthful indiscretion," when he experimented with a Windows PC. But the last attempt didn't work out so well.

Cook ultimately found his purpose when he arrived at Apple 20 years ago. That's where he met Apple co-founder Steve Jobs, who had a passion for tech coupled with a need to serve people. He encouraged the class to infuse their values and humanity in the things they create and build. Cook stressed the importance of that message by sharing an anecdote from his meeting with Pope Francis last year. The Pope told Cook "never has humanity had such power over itself, yet nothing to ensure it will be used wisely."

While Cook's message to the class was clear and serious, he also poked fun with the graduates. He noted that MIT is known for pulling pranks, or what they call "hacks." He listed several real pranks and ended the ranking with a take over "of the president's Twitter account," noting that the 3 A.M. time stamps on the tweets were a clear sign that college students were behind the messages.

Under Cook's leadership, Apple has launched products like the Apple Watch and the newly announced HomePod. Cook became the CEO of Apple after Jobs stepped down in August 2011. Prior to that, he was the company's chief operating officer.

"If you choose to live your life at the intersection of technology and the people it serves," Cook says. "If you strive to create the best and do the best, not just for some, then today, all of humanity has good cause for hope."