In Shakespeare's Hamlet, the players come to Elsinore to do what they do, put on plays. They are a traveling group of actors. They are entertainers. In short, that is the answer to your question.
In terms of the drama, they serve the function of presenting the "play-within-the-play," which not only draws attention to the theme of acting/pretending/seeming in the play, but also draws attention, after a bit of manipulation by Hamlet, to Claudius's guilt as the murderer of King Hamlet. Claudius's reaction to the murder scene that presents a murder similar to that he committed, convinces Hamlet that Claudius is, indeed, guilty of murdering his father.
The players also provide opportunities for Hamlet to ruminate on acting theory, and serve as catalyst for Hamlet's "Hecuba" soliloquy.
Again, though, in short, the players come to put on plays.