The black group in the upper corner has two liberties, as does the main white group before you play that last piece. Therefore, if you had instead decided to play elsewhere on the board, white could have decided to capture the black group and done so before you could save it.
With that final spot filled in, you are now guaranteed to capture the white group before the black group is captured. That means you are free to play elsewhere on the board without being in danger of losing this corner - if white ever plays here you can always safely respond.
Superficially, it may look like that last piece is easily captured, but every move that white could make has a response that puts them back at one liberty away from capture, so it's not as vulnerable as it appears.