Kaguya was once the princess of the Lunarians, a moon-dwelling race who looked down on humanity. She drank the forbidden Hourai Elixir to gain immortality, a crime that got her exiled to Earth over a thousand years ago. Landing in what's now central Japan, she was discovered by a bamboo cutter and ended up living among the very humans the Lunarians despised. Surprisingly, she fell in love with her new home.
Her otherworldly beauty attracted marriage proposals from across Japan, but she had no intention of accepting—at least not easily. She set the Five Impossible Requests as trials for her suitors, and unsurprisingly, none of them pulled it off.
When lunar emissaries eventually showed up to bring her back, she'd already been forgiven. The Lunarians decided her punishment was over. But Kaguya didn't want to go. She'd grown too attached to Earth. With help from her friend Eirin, she gave the emissaries the slip and escaped to Gensoukyou, where the two of them set up a new life hidden in Eientei, an old mansion deep within a bamboo forest.
During Imperishable Night, Eirin had stashed Kaguya in a secret pathway to keep her away from any Lunarians who might come looking. The heroines found her anyway, though, and forced a confrontation that ended with Kaguya unleashing her power of eternity in a last-ditch effort to break the spell of imperishable night. She eventually gave in, and the true moon was restored.
These days she lives pretty casually at Eientei, occasionally putting on exhibitions of Lunarian treasures for Gensoukyou's residents. Her long isolation has made her lonely enough that she genuinely enjoys when guests stop by to hear her stories.
Content compiled by AnimeList.moe from publicly available sources.