In spite of being close to Harry, why did Dumbledore never mention his past to him? Why was Dumbledore's past revealed only after his death?
I assume you're asking here about his personal life, rather than the Hallows.
And the answer, in large part, is because he was very ashamed of it.
When Harry and Dumbledore discuss the Hallows, which led to his friendship with Grindelwald and the death of his sister, note how Dumbledore acts.
'What are you talking about?' asked Harry startled by Dumbledore's tone, by the sudden tears in his eyes.
'The Hallows, the Hallows,' murmured Dumbledore. 'A desperate man's dream!'
'But they're real!'
'Real, and dangerous, and a lure for fools,' said Dumbledore. 'And I was such a fool. But you know, don't you? I have no secrets from you any more. You know.'
'[...] It was a Cloak the likes of which I had never seen, immensely old, perfect in every respect ... and then your father died, and I had two Hallows at last, all to myself!'
His tone was unbearably bitter.
Harry Potter and the Deathly Hallows - pp.571-2 - Bloomsbury - Chapter 35, King's Cross
And then, listen to how he speaks about the events themselves.
'Oh yes,' said Dumbledore faintly. It seemed that he forced himself to meet Harry's eyes. 'You know what happened. You cannot despise me more than I despise myself.'
'But I don't despise you -'
'Then you should,' said Dumbledore. He drew a deep breath. 'You know the secret of my sister's ill-health, what those Muggles did, what she became. You know how my poor father sought revenge and paid the price, died in Azkaban. You know how my mother gave up her own life to care for Ariana.
'I resented it, Harry.'
Dumbledore stated it baldly, coldly. He was looking, now, over the top of Harry's head, into the distance.
'I was gifted, I was brilliant, I wanted to escape. I wanted to shine. I wanted glory.
'Do not misunderstand me,' he said, and pain crossed the face so that he looked ancient again. 'I loved them. I loved my parents, I loved my brother and my sister, but I was selfish, Harry, more selfish than you, who are a remarkably selfless person, could possibly imagine.'
Harry Potter and the Deathly Hallows - p.573 - Bloomsbury - Chapter 35, King's Cross
Dumbledore was very ashamed of his past, and you can see here how he can hardy bear to admit his selfishness to one so selfless as Harry.
Recall how he was tortured by visions of these events by the Horcrux Potion in the cave.
Recall how he runs from his past. He does not confront it. He delays meeting Grindelwald, despite death and destruction, to keep his past behind him.
'You are very kind, Harry. But while I busied myself with the training of young wizards, Grindelwald was raising an army. They say he feared me, and perhaps he did, but less, I think, than I feared him.
'Oh, not death,' said Dumbledore, in answer to Harry's questioning look. 'Not what he could do to me magically. I knew that we were evenly matched, perhaps that I was a shade more skilful. It was the truth I feared. You see, I never knew which of us, in that last, horrific fight, had actually cast the curse that killed my sister. You may call me cowardly: you would be right. Harry, I dreaded beyond all things the knowledge that it had been I who brought about her death, not merely through my arrogance and stupidity, but that I actually struck the blow that snuffed out her life.
'I think he knew it, I think he knew what frightened me. I delayed meeting him until, finally, it would have been too shameful to resist any longer. People were dying and he seemed unstoppable, and I had to do what I could.'
Harry Potter and the Deathly Hallows - p.575 - Bloomsbury - Chapter 35, King's Cross
But he does not get closure from this, he is still wrapped in self-loathing and shame. He has not made amends for his past.
Secondly, of course, because there are more important things at stake than autobiography.
'[...] I spend time with Harry because I have things to discuss with him, information I must give him before it is too late.'
Harry Potter and the Deathly Hallows - p.549 - Bloomsbury - Chapter 33, The Prince's Tale
Regarding the Hallows specifically, of course Dumbledore explains why he didn't tell Harry that himself:
'Harry, I only feared that you would fail as I had failed. I only dreaded that you would make my mistakes. I crave your pardon, Harry.'
Harry Potter and the Deathly Hallows - p.571 - Bloomsbury - Chapter 35, King's Cross
Why was Dumbledore's past revealed only after his death?
let's start with this one. As his younger brother, Aberforth says with not a small amount of bitterness:
“I knew my brother, Potter. He learned secrecy at our mother’s knee. Secrets and lies, that’s how we grew up, and Albus . . . he was a natural.” ~Harry Potter and the Deathly Hallows
So Aberforth characterizes his older brother as secretive by nature and nurture.
Albus was raised that way by his mother whom aunt Muriel describes as a "proud and very domineering"1 witch. Probably wasn't easy, attending Hogwarts and enduring all the whispers about his father slaughtering muggles and not being able to defend him, lying about his sister being home-schooled because of her fragile health, fearing that a slip of his tongue would cause Ariana to be taken away. So Albus had to distance himself from his fellow students, he couldn't confide in them. And then the death of his mother...making him the head of the family, responsible for his brother and sister, which also meant he had to sacrifice his career and return to
some backwards village Godric's Hollow and keeping his mouth shut.
And when he does confide in someone and makes a friend, his intellectual equal and lover, Gellert Grindelwald, it ends very badly. No wonder after that Dumbledore blames himself and decides not to trust anyone.
The conclusion he arrived wasn't "secrets are bad, my family was wrong for not seeking professional help of the St. Mungo medwizards and failing to provide competent medical care for my sister. Locking her in a house and keeping her state a secret caused the death of too many people." Instead he blames himself for not keeping the secret better and not 'protecting' his sister but being selfish and easily corrupted by his own desires and aspirations.
Probably because of his upbringing and the circumstances of Ariana's death is why later the Headmaster of Hogwarts and the Head of the Order of the Phoenix doesn't confide in anyone; He only gives the essential information to his
pawns subordinates, just enough so they could carry out his instructions.
The Order members are used to it, and seldom question his judgement.
“It isn’t our business to know,” said Lupin unexpectedly. He had turned his back on the fire now and faced Harry across Mr. Weasley. “It’s Dumbledore’s business. Dumbledore trusts Severus, and that ought to be good enough for all of us.” “But,” said Harry, “just say — just say Dumbledore’s wrong about Snape —” “People have said it, many times. It comes down to whether or not you trust Dumbledore’s judgment. I do; therefore, I trust Severus.”
There it is, blind trust. The Order members, McGonagall and others ready to risk their lives because they trust his morals and judgement.
Even Molly Weasley, who usually has very negative opinions about people endangering teenagers and sending them to dangerous missions by themselves doesn't argue that Dumbledore might have been wrong, only that Harry misunderstood him:
“Dumbledore didn’t want anyone else to know, Mrs. Weasley. I’m sorry. Ron and Hermione don’t have to come, it’s their choice —” “I don’t see that you have to go either!” she snapped, dropping all pretense now. “You’re barely of age, any of you! It’s utter nonsense, if Dumbledore needed work doing, he had the whole Order at his command! Harry, you must have misunderstood him. Probably he was telling you something he wanted done, and you took it to mean that he wanted you —” “I didn’t misunderstand,” said Harry flatly. “It’s got to be me.”
and that's the end of the discussion. Molly has no further objections. If it was Dumbledore's will, then even she can't oppose it openly, however unreasonable it seems to her.
Dumbledore is brilliant, talented, charismatic. People seek his advice, many follow him and risk their lives on his orders and believe he is infallible. All this placed a great responsibility on him and convinced him that he must make decisions for others. The Minister of Magic should follow his advice on fighting Voldemort, his spy, Snape, has to risk his life for information, the Order and Harry should trust his decisions without lengthy explanations and so on.
Being in such a position he was probably afraid that if he would appear unsure in himself and admit he made mistakes, saying: 'I am easily corrupted by power. My desire to find the Hallows and reform society for the greater good with my friend Gellert Grindelwald last time cost me my sister' he would lose the support and respect of his followers, and he won't be able to
control guide them.
Dumbledore once said that Voldemort has no friends, only followers. It's the same with Dumbledore. He thinks himself intellectually superior, the only one who can master a plan to defeat Voldemort. He never discussed his strategy with anyone: the only one who knew the finer points of Dumbledore's plan was Snape, and he wasn't offered much choice either, Dumbledore never asked his opinion, pretty much just ordered him to carry out his instructions. Dumbledore certainly seemed to think that's the only way to do things: working on his plan alone, in complete secrecy, never trusting anyone more than necessary, giving only the essential instructions to follow.
In spite of being close to Harry, why did Dumbledore never mention his past to him?
They were in a mentor- mentee relationship. While Dumbledore was very fond of Harry and impressed by his moral integrity and bravery, he wasn't especially open with Harry, shared only the things in his opinion Harry needed to know to succeed in his mission to defeat Voldemort and was very elusive about things not concerning this goal. While he was alive, he never told Harry about the Hallows, his complicated relationship with GG and the mistakes he made when he was young. Probably the same reasons apply as in the previous question, plus the age gap.
Dumbledore himself gives a few reasons in the books:
When Harry complained why was he so secretive in his fifth year, which may have caused Sirius's death, Dumbledore said:
"I was trying, in distancing myself from you, to protect you. An old man’s mistake . . .” Harry remembered the feeling that a dormant snake had risen in him, ready to strike, on those occasions when he and Dumbledore made eye contact. “Voldemort’s aim in possessing you, as he demonstrated tonight, would not have been my destruction. It would have been yours. He hoped, when he possessed you briefly a short while ago, that I would sacrifice you in the hope of killing him.” ~Harry Potter and the Order of the Phoenix*
Which isn't convincing. After all, Dumbledore could've been open with Harry, explaining to him (in a letter if necessary) why the Occlumency lessons were so important and why he needed to keep a distance from Harry. Instead he chose the Mushrom Treatment .
And then we have the explanations Spiritual Dumbledore gives why he was reluctant to share information with Harry:
reason 1: He distrusted Harry, felt he'd be tempted by the Hallows:
“The Deathly Hallows,” ... “Can you forgive me?” he said. “Can you forgive me for not trusting you? For not telling you? Harry, I only feared that you would fail as I had failed. I only dreaded that you would make my mistakes. I crave your pardon, Harry. I have known, for some time now, that you are the better man.”
reason 2: Dumbledore felt guilty taking the cloak of invisibility while the Potters were in mortal peril
It was a Cloak the likes of which I had never seen, immensely old, perfect in every respect . . . and then your father died, and I had two Hallows at last, all to myself!” His tone was unbearably bitter. “The Cloak wouldn’t have helped them survive, though,” Harry said quickly. “Voldemort knew where my mum and dad were. The Cloak couldn’t have made them curse-proof.” “True,” sighed Dumbledore. “True.”
reason 3: Dumbledore characterizes himself as a selfish, despicable person, the opposite of Harry. Implying he didn't want Harry to despise him.
You cannot despise me more than I despise myself.” “But I don’t despise you —” “Then you should,” said Dumbledore. He drew a deep breath. .. You know how my mother gave up her own life to care for Ariana. “I resented it, Harry.” Dumbledore stated it baldly, coldly. He was looking now over the top of Harry’s head, into the distance. “I was gifted, I was brilliant. I wanted to escape. I wanted to shine. I wanted glory " ... "I was selfish, Harry, more selfish than you, who are a remarkably selfless person, could possibly imagine. "
reason 4: Dumbledore was reluctant to face the truth himself, much less to tell about it to others:
It was the truth I feared. You see, I never knew which of us, in that last, horrific fight, had actually cast the curse that killed my sister. You may call me cowardly: You would be right. Harry, I dreaded beyond all things the knowledge that it had been I who brought about her death, not merely through my arrogance and stupidity, but that I actually struck the blow that snuffed out her life.
As usual, Dumbledore contradicts himself, for either he thought Harry is a much better, selfless person, unlike himself, that's why he was reluctant to tell Harry about the mistakes he made in his youth, or he distrusted Harry and suspected that the boy may be corrupted by the Hallows, selfishly taking them for himself, that's why he kept them a secret.
- Harry Potter and the Deathly Hallows, CH 8 - The Wedding