Hamlet, Shakespeare's greatest work, is a tragedy
Shakespearean canon: the 38 plays written by Shakespeare, considered to be his complete dramatic works
Hamlet is the greatest Shakespearean tragedy because it shows the struggles of Danish royals with core elements like grief, betrayal, and family. Shakespeare brilliantly displays what it means to feel alienated and be in existential despair through Hamlet's character, a Danish prince. The soliloquy, "To be or not to be," is one of the greatest anthems that has been adapted and retold via various mediums.  Through the mastery of portraying human emotions, which are crucial in every person's life, Shakespeare combines art, poetry, drama, philosophy in Hamlet, marking it as one of the greatest tragedies.  Every year, Hamlet is performed in London and some of his plays have been adapted as retellings like the Lion King, Ophelia, and The Dead Fathers Club.
Whether or not Hamlet is Shakespeare's best work is a subject for much debate: it's a matter of taste, and many people prefer other plays. The fact it's a tragedy doesn't necessarily mean tragedy is the best form for displaying Shakespeare's talents. His comedies are top-rated, and he makes use of unusual narrative devices in the histories. All the forms of his plays are significant in displaying his skills. Hamlet is also debated to be more of a revenge play than a tragedy because Prince Hamlet doesn't avenge his father's death but rather contemplates it beforehand.  So it cannot be categorized as one of the greatest tragedies.
Hamlet is the most popular play in the Shakespearean canon, and many actors find playing Hamlet an important moment for their career. The versatile tragic form allows Shakespeare to display his full talent and meditate on important themes such as identity and family.
Rejecting the premises
There can be no definitive answer on what counts as Shakespeare's greatest work. Just because Hamlet, a tragedy, is very popular, it doesn't mean that tragedy is immediately the best form for Shakespeare to display his literary skills.