Answer:
The rationale of The Gasp might be as grim and straightforward as this: Eliza gasps because she dies. She joins her husband, her son, and all of the other musical characters on "the other side," the musical's recurring euphemism for what comes after death.
At the end of the musical, in the song "Who Lives, Who Dies, Who Tells Your Story," Eliza explains how she devotes her life to continuing Hamilton's legacy, whether through establishing an orphanage or compiling his papers. The song (and show) ends on an ambiguous note: Eliza gasps—as if she's seen a horrifying apparition— and the stage goes black.
Explanation: