Chief Justice John Roberts' speech wishing new grads 'betrayal,' 'bad luck' and 'failure' has gone viral on Twitter

Brooks Kraft | Getty Images

Commencement speakers are expected to give graduates useful advice and motivation, and ultimately, extend them good wishes for the rest of their journeys.

But at a recent ceremony, America's top judge refused to wish students good luck and instead said he hoped they failed — because ultimately that will help them succeed — and to do so with grace.

Chief Justice John Roberts' unconventional commencement speech at Cardigan Mountain School, where his son graduated from ninth grade in June, has gone viral on Twitter.

John Roberts Speech Twitter

In his address, Roberts acknowledged that, in most commencement speeches, even influential ones from icons like Tim Cook, Oprah Winfrey and Mark Zuckerberg, there are two problems: The graduates are impatient, and speakers repeat the same ideas and advice.

Roberts tried to solve those problems by delivering an unexpected lesson on how crucial it is to fail for learning perseverance. By wishing bad luck and even betrayal for the students he addressed, he said he hoped listeners would learn the importance of justice, friendship, loyalty, sportsmanship and compassion.

"And as far as the confidence goes, I think you will appreciate that it is not because you succeeded at everything you did, but because with the help of your friends, you were not afraid to fail," he said.

He also pointed out that "whether I wish these things or not, they're going to happen. And whether you benefit from them or not will depend upon your ability to see the message in your misfortunes."

Although Roberts made the point more bluntly than some, he is far from the only successful person to argue that losing teaches you how to win. Here are six influential leaders who have said that failure, and how you bounce back from it, is critical to your ultimate success.

Mark Cuban’s best advice for college grads
Mark Cuban’s best advice for college grads

Billionaire investor Mark Cuban

After graduating from Indiana University in 1981, tech entrepreneur Mark Cuban said he had quit or gotten fired from three consecutive jobs.

"One of my favorite sayings is, it doesn't matter how many times you fail, just have to be right once. Then everybody can call you an overnight success," the star of ABC's "Shark Tank" said. "I've failed a company that sold powdered milk, I failed the jobs I've gotten fired from. And all those were learning experiences."

Star athletes Michael Jordan, Serena Williams and Peyton Manning

In a new Gatorade ad titled "The Secret to Victory," the athletes agree that overcoming defeat is the essential ingredient to achieving career success.

"You want to know the secret to victory?" Jordan asks at the beginning of the ad. "Fail to make the varsity team."

"It's not wanting to win that makes you a winner; it's refusing to fail," Manning once said.

Best-selling author J.K. Rowling

In 2008, J.K. Rowling gave a now famous commencement speech at Harvard in which she detailed the benefits of failure.

"Now, I am not going to stand here and tell you that failure is fun," Rowling said. "So why do I talk about the benefits of failure? Simply because failure meant a stripping away of the inessential."

"Failure gave me an inner security that I had never attained by passing examinations. Failure taught me things about myself that I could have learned no other way," Rowling said.

The tree-hugging side of a tequila icon
The tree-hugging side of a tequila icon

Patron tequila co-founder Paul DeJoria

Although serial entrepreneur John Paul DeJoria once struggled to afford a 99 cent happy-hour margarita, he is now worth about $3 billion, according to Forbes. DeJoria told CNBC he had failed many times before co-founding hair company Paul Mitchell Systems and tequila maker Patron.

His advice to others who want to get ahead?

"Be prepared for a lot of rejection," he said, "because you are going to get it. If you are prepared for it, it's not going to hurt you as much."

"Be just as enthusiastic on Door 101, [even] if 100 have been closed in your face. Eventually you're going to do it."

Like this story? Like CNBC Make It on Facebook.

Don't miss: The most influential and effective leaders have these 6 traits

Will Ferrell speech to USC's students will inspire you to take more risks
Will Ferrell speech to USC's students will inspire you to take more risks

Disclosure: CNBC owns the exclusive off-network cable rights to "Shark Tank."