His purpose as a character in the story is to be part of a series of horrible things that Geto witnesses to break him. If haibara didn’t die on a mission then Geto might not have gotten so disillusioned with Jujutusu society’s mission to defeat curses and save regular humans.
he died after he left geto n yuki to talk alone, one of the reasons geto changed