The in-universe explanation (to treat Greek mythology like fantasy fiction, and that’s not that absurd really) is
He was renamed Heracles [“glory of Hera”] in an unsuccessful attempt to mollify Hera. (Heracles – Wikipedia)
Stepping behind the curtain, in his monograph on Greek religion (p. 322), Walter Burkert says the name might be a coincidence; but he thinks it likelier that Heracles being subject to Eurysthenes and his protector goddess Hera, and the multiple instances where Heracles cross-dressed, point to a hero whose very point was that he could fall from being the son of Zeus to being disempowered (oppressed by a female goddess, cross-dressing like a woman).