While sleeping one night, Ash Ketchum
had a dream where Solgaleo and Lunala appeared to him at the Altar of the Sun and moments later Starcloud came out from the light. He made a promise to them to watch over the Cosmog. The next day on the way to school, Tapu Koko
appeared and directed Ash Ketchum
to where the Cosmog was sleeping. He picked it up and took it to the Pokémon School where no one was able to identify the type of Pokémon that it is.
decided to call the Cosmog "Starcloud" because its inner body shines like twinkling stars and it floats gently in the air much like a cloud, so its name is a combination of the the words star and cloud.
It evolved into Nebby (Cosmoem)
after being released by Faba
from his device that stopped it from being able to Teleport.