In theory, the idea was to ensure a smooth succession of power from father to son.
Henry II became king after a period of English history known as 'The Anarchy', which was a long civil war between Stephen I and Matilda over who should rule England. When Henry I died he named Matilda his heir, but his closest male relative (and it was customary for the oldest male to inherit) was Stephen I. The subsequent civil war seriously damaged the kingdom and the ending compromise was that Stephen could be king as long as Matilda's son, Henry II, succeeded him. Henry II came to power fully aware of how ruinous a disputed succession could be and of the unfortunate fact that there was no guarantee of smooth succession even if he clearly named an heir.
But in France at the time, the kings there had a practise of crowning the king's son as co-king. Over time, the son would take on more responsibilities until the death of the father. At that point, the son could just keep on ruling, but now as the main king rather than the subordinate son. The exact powers and responsibilities given to the son varied according to the will and personalities of the father and the son - fathers who liked power did not like giving it away to their son, and sons who were a bit dim were not given as much free reign. But whatever the specific arrangement between father and son, the effect was always a smooth succession. Henry II wanted that for his kingdom, so he imitated their practise of crowning the heir as co-king.
But Henry the Young King had no power, so what was going on? To quote William Chester Jordan, he was 'willful, resentful, peevish, stupid, and altogether charming.' Henry the Young King was a charming and generous individual, but he was also a bit thick. Henry II was also loathe to give up any meaningful power to anyone. This meant that Henry the Young King was never going to get meaningful responsibilities no matter how forcefully he asked.
So the reason Henry II crowned his son was to try and get a smooth succession upon Henry II's death in order to avoid a costly civil war in the likely event of the succession being disputed. It failed because Henry II was not the sort of man who liked giving up powers, and Henry the Young King was not the sort of man who'd put those powers to good use if he had them. Henry II seems to have considered the idea a failure, given that he did not attempt to co-crown another of his sons when Henry the Young King died.
Soruces
Jordan, William Chester. "The Historical Afterlife of Two Capetian Co-Kings Who Predeceased Their Fathers." Louis VII and His World. Brill, 2018. 114-125.
Lewis, Andrew W. "Anticipatory association of the heir in early Capetian France." The American Historical Review (1978): 906-927.