From the Super Mario Wiki
The Giant Star can be obtained by defeating Bowser in the final Bowser level, Bowser in the Sky. After being defeated, Bowser will vanish,revealing the final star, the Giant Star. By grabbing this star, Mario will transform into Wing Mario and start flying. After returning to Princess Peach's Castle, Mario then uses the Giant Star to release Princess Peach from the stained glass window she was trapped in above the entrance to the castle.
Unlike other Power Stars, the Giant Star will not increase Mario's Star total once collected; this is probably because the game isn't saved when this star is collected. This means that 121 Power Stars appear in Super Mario 64 (151 in the DS remake). This means that the player does not have defeat Bowser to complete the game with the maximum number of stars.