3,000 years prior to the events of Pokémon X and Y, a war broke out in Kalos. This long conflict was drawn out and many lives were lost. People treated Pokémon with special powers as mere tools in their conflict, so they gathered lots of Pokémon, including Pokémon with unique powers. In order to emerge victorious, the soldiers believed that they needed even more powerful Pokémon. AZ loved his Floette, which he had received from his late mother, but it was forcefully taken from him by the soldiers and became just another sacrifice in the war.
AZ received the body of his beloved Pokémon several years later, and out of unspeakable grief, he built a machine to restore it to life. This machine was powered up by the energy of XerneasX/YveltalY/bothZA. He succeeded, but unable to overcome his despair, he turned the machine into the ultimate weapon, with which he destroyed both sides of the conflict, ending the war. His Floette, disgusted with the fact that the machine was powered by the life energy of other Pokémon, left him. Due to his exposure to the ultimate weapon, he had his lifespan extended and gained an incredible height.
(Source: Bulbapedia)
Content compiled by AnimeList.moe from publicly available sources.