Shakespeare did not invent "Hamlet." The name derives from the medieval Scandinavian legend of Amleth (Old Norse Ámlóði), recorded by:
Ámlóði → Latin Amlethus → French Hamlet → English Hamlet. Etymology may relate to "fool" or "trickster" (from *ama* "to vex" + *lóði* "fool"), fitting the feigned-madness motif.
He deepened the revenge plot into existential tragedy but retained the core: prince, usurping uncle, mother's hasty remarriage, feigned madness, ultimate vengeance.