What's most important to note here is the capital "D" in Dane. Hamlet is not merely referring to himself as a citizen of Denmark, but as The Citizen of Denmark--i.e., the rightful king. We have heard Hamlet mull his future, his past, his place in the world, and his thoughts on the afterlife. Just moments prior to this rash declaration, he philosophized on the fleetingness of life and worldly status as he mentions that even Alexander the Great (or what is left of him) could now be part of a cork stopping a barrel. But, despite all that we've heard Hamlet's thoughts on to this point, we haven't really heard anything about whether or not he wants to be King...except for his wry comment to Rosencrantz and Guildenstern in 3.2 when he states he "lacks advancement." This is an oblique commentary on his royal status (or lack of). But here, in 5.1, he recklessly jumps forward, filled with rage at Laertes, and declares himself the rightful King.
Why does he choose to do so now? Perhaps his rage alone propels him to admit this deeply held thought. Perhaps, since he is so bent on showing Laertes that he loved Ophelia more, he feels he can "one-up" Laertes even more by identifying himself as royalty. He then follows up this bold, public statement by mentioning to Horatio in 5.2 how Claudius "popped in between th' election and my hopes," indicating that he was, indeed, hoping to be elected as King.
This begs the larger question: WAS Hamlet solely motivated to kill Claudius just to avenge his father's death? Or did he have some selfish motives as well (knowing that he would be the shoo-in for King if Claudius weren't around anymore...)?
Hamlet is asserting his identity. Earlier in the play, he has contemplated his death, his act of revenge and he has lost himself. Here he is asserting who he is. The fact that he refers to himself as the Dane, implies he is the citizen of Denmark and he will fight for justice, not just for himself but for his country.
What is relevant is this moment that he reveals his identity. Why does he wait till Ophelia dies to assert himself? Is to prove to Laertes that he loved Ophelia more or is it that now Ophelia is dead he can act? Lacan believed that Ophelia was the reason Hamlet was holding back, maybe here Lacan is right.
Just an additional note, a lot of strong characters assert their identity before their death i.e. Cleopatra from Shakespeare's Anthony and Cleopatra and the Duchess from Webster's Duchess of Malfi. Maybe here there is a foreshadowing of Hamlet's death as well his assertion of his identity.