It is noted that Hamlet is jealous of Laertes' show of brotherly love for Ophelia when Laertes is the first to express his love by jumping into Ophelia's grave. Hamlet says;
Hamlet does this out of competition to show who loves Ophelia more. It seems Hamlet is offended by Laertes' show of love for his sister and wants to prove that he is just as capable of selfless love and sacrifice. He jumps into the grave to challenge Laertes. (Act 5, Scene 1).
When Hamlet meets his father's ghost and hears it speak against Claudius and Gertrude, Hamlet assumes revenge as his goal. (Act 1, Scene 5). As Hamlet has a purpose in life, he cannot be deemed suicidal. He feigns madness to refute his declarations of love to Ophelia. Hamlet knows that he has to achieve his goal of justification against the king and it is treason punishable by death. He does not wish to involve Ophelia in his dangerous mission. Hamlet tries to kill Claudius when he was alone but Hamlet changes his mind when he thinks that Claudius might achieve martyrdom if he dies while in prayer. (Act 3, Scene 3).
When Hamlet knows that Rosencrantz and Guildenstern carry King Claudius' letter commanding himself, Hamlet, to be put to death in England, he acts craftily to save his own life. He substitutes his own letter with the new command that his traitors be sentenced to death instead. ...