The Answer: Stardust is used to power up your Pokémon so they can become stronger for battling Gyms.
Stardust is collected every time you catch a Pokémon. I have noticed that you get about 100 stardust points for every Pokémon that you catch. Once stardust is collected, you can use it to power up any Pokémon on your team. Another way to collect stardust is by positioning Pokémon at a Gym. The Pokémon will earn a stardust reward every day. Stardust is essential if you want to stand a chance against higher-level trainers.
QUICK TIP: Save your Stardust to power up your favorite Pokémon. Do not waste it earlier on a Pokémon that you do not plan to use to attack Gyms when the time arises.