From the Super Mario Wiki
The Rainbow Star is an item that appears in Super Mario Galaxy and Super Mario Galaxy 2. When collected, it transforms Mario into Rainbow Mario (or Luigi into Rainbow Luigi), causing him to become rainbow-colored and leave a trail of light behind him whenever he runs. In this form, he is invincible, can break through certain objects and obstacles, can run faster, and can jump both farther and higher. If Mario keeps running without stopping, he'll get Star Bits. As the power-up begins to wear off, the music, along with Mario's running speed, will get faster and faster until it wears off completely. The Rainbow Star might have been colored differently to differentiate it from Power Stars, which are, in both Super Mario Galaxy and Super Mario Galaxy 2, the items that must be collected in order to complete the game. The theme that plays after collecting a Rainbow Star is a remixed version of the classic invincibility music.
- The Rainbow Star is the only power-up in Super Mario Galaxy 2 that does not appear as a souvenir in the engine room of Starship Mario.