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 explode, 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 there are 121 Power Stars in total in Super Mario 64 (151 in the DS remake).