The ever wise Horatio knows that something's up and advises his friend Hamlet not to attend the fencing competition. He doesn't know that Laertes and Claudius plan to have Hamlet killed with a poison-tipped rapier, but he does know that the two men have something nasty in store for his friend.
Even Hamlet suspects there's something fishy going on. He too has a bad feeling about the fencing competition:
But thou wouldst not think how ill all’s here about my heart. (Act V Scene ii).
Yet he still agrees to participate. The reason is that, by this stage in the play, Hamlet's pretty much resigned to his fate. If he should be killed by Laertes, then so be it. Hamlet doesn't just see his death as inevitable, he sees it as part of a bigger picture, in which every life and every death has some significance, even that of a little sparrow. For the first time in the play, Hamlet seems to be at peace with himself, and so he willingly goes off to his fatal duel with Laertes without fear of the consequences.