In brief, by ignoring Yoda's admonitions and going in armed and fearful, Luke had failed to demonstrate the emotional mastery that was needed to inoculate against the temptations of the Dark Side.
Luke had already demonstrated throughout much of his life high tension, anxiety and impatience. These qualities were alive and well when he first encountered Yoda in the flesh, and Yoda well understood that Luke would have to learn to control his emotions, to discipline his impulses and to face his fears with a cool head. Failure to do so would mean as sure a danger of falling into the Dark Side as exists.
Yoda made it clear that the cave contained only what Luke "took with him" and that he would not need his weapons. Luke refused to take a coolheaded approach to his fears, refused to listen to Yoda: convinced that mortal peril awaited him in the cave, he took his weapons.
The only mortal danger to Luke was himself - his own lack of self-control and his inability to temper his negative emotions - as his face beneath the Vader mask proved, insinuating that with this baggage he was in line to become an agent of evil, and lose his life.
You'll notice also that just before entering the cave, Luke was admonished that a Jedi should use his powers for defense only, never to attack. Yet in his brush with Cave Vader, who drew the lightsaber first? Luke.
This led to Yoda not fully trusting Luke: he was unprepared emotionally to deal with the physical and psychological nightmare of a confrontation with such a powerful enemy. Luke once again refused the advice and plunged in, convinced his gut instinct was right. So what happened? Luke was able to contribute precisely nothing to the initial rescue of his friends and indeed may have put them in further danger by giving them another rescue task before they left. He once again drew his lightsaber first against Vader, and despite his skillfulness in combat he could not stay focused enough to avoid suffering a traumatic injury. Indeed the only positive aspect of Luke's botched intervention was that it taught him once and for all just how much peril he was in because of his impulsiveness and served as catalyst the much-needed process of calming him down.