Prime Minister Scott Morrison drew on his own experience in telling nearly 6000 high school students not to be afraid of failing.
Mr Morrison was speaking on Wednesday at the gathering organised by Stand Tall, a charity run by volunteers to counter youth suicide and bullying.
One hundred students from Endeavour Sports High School, 82 from Sutherland Shire Christian School and 50 from Kirrawee High School were among those present at the International Convention Centre, Darling Harbour.
They roared when Mr Morrison asked at the outset, "Are there any Sharks fans in the house?"
Mr Morrison, who has made youth suicide one of the new government's top priorities, told the students, "If you haven't failed, you've learnt nothing".
"And when things fail, it's a matter of just looking at it as an opportunity to learn from that experience."
Mr Morrison referred to his bid for Liberal Party preselection for the seat of Cook for the 2007 election.
He initially received only only eight votes, while the winner Michael Towke gained 82 votes.
Mr Towke was later controversially dis-endorsed, and Mr Morrison was preselected in his place.
Mr Morrison did not go into the background, but told the students, "I got eight votes the first time I ran".
"I had to go home and tell Jen, 'It didn't go terribly well,' " he said.
"And I had to share with [her] that we'd put our lives on hold for a long period of time, to try and seek this opportunity, and it just didn't come.
"But we learned from that and we didn't give up and we kept going forward.
"So the first thing to do is if you encounter failure in your lives - because you will, and if you don't, it means you're not trying things - then it's important not to see that as the end of the road, but importantly as the start of another road, and one you can walk tall on."
Mr Morrison's second piece of advice to the students was, "What's good for your body, is good for your mind".
"If you keep your body healthy, you can keep your mind healthy as well," he said.
"And it's important that when you keep your mind healthy, you can stay positive on the things that when you're facing challenges in life.
"So when it comes to keeping your body healthy, whether it's making sure you get enough sleep, whether you get your physical activity and your exercise, or you ensure that you eat well and, you know, it's all right to have fun every now and then.' "
Mr Morrison said, to cope with the stresses of his job, he tried to swim most days.
"You'll find me down at the Caringbah pool, or the North Sydney pool [near Kirribilli House] or anywhere I can find a pool - and yep, I do wear the Speedos, so I don't let the cameras in. Ever. That's never happened guys, it's never going to happen".
Mr Morrison told the students, "Sometimes you can think, 'I don't matter, and the problems that I have are just too big, and no one cares, and no one thinks I matter' ".
"But what Stand Tall is all about is making sure that you know you matter," he said.
"And in life, lots of things can be taken away from you. Lots of things. You can lose things, you can lose friends, you can lose money, you can... all sorts of things can happen. Sometimes you can lose your health.
"But the one thing that can never be taken away from you - and this is really important to understand this - is your value. Your value as an individual human being, as a man, as a woman, as a son, a daughter, a brother, a sister. You matter very, very much."
Scott Morrison's full speech: https://www.pm.gov.au/media/stand-tall-event-sydney