The same role Dumbledore, Gandalf, Obi wan Kenobi, master roshi , jiraya and many more play in their respective universes. The role of a mentor who dies(sometimes intentionally) inspiring his protegee.
Shanks fits that mold very well.
Basically the mentor figure is a strong character who is a steadfast ally of the protagonist. With them with the protagonist during the climatic struggle of the arc or the entire story, the situation might not feel that much dire. Things would always feel in control of the protagonist since he has a such a powerful ally alongside him. The villain might not feel that threatening even. To increase the stakes, the thrill and the suspense of the climatic struggle, the mentor needs to go. What better way to accomplish this than to have the villain himself off the mentor thus tying up two ends together while also giving even more emotional weight to the protagonist who is going to inadvertently defeat the villain either by force or otherwise .
tldr- shanks gonna hype up bb.