According to Vegapunk, the Ancient Kingdom that predated the World government was vast and possessed technological advancements that even his genius could not attempt to replicate. This kingdom probably functioned as a utopia: one where food and resources were abundant, diseases and poverty non-existent, and where the residents were satisfied by the security and comfort of its walls. Every want and need were within arm’s reach.
If we are to believe to Joy Boy was anything like Luffy however, then he simply was not satisfied by this lifestyle. His desire for freedom and adventure led him to run away from the kingdom, a criminal act at the time, and as the “first man to take the seas” he would be known as the first pirate. Unbeknownst to him, his contact with the external world would lead to the downfall of his Homeland.
On his adventures he came across a multitude of new biomes, races, and would even come to be known as a hero and later the mythological figure known as Nika to some cultures, all thanks to his “Devil” power. Although these powers were like magic to the outside world, these were the norm in the Great Kingdom.
I theorize that nearly ALL residents of the Great Kingdom possessed these powers. They probably did not start as Devil Fruits, but as artificial genetic modifications employed by the Great Kingdom. I don’t believe this is unrealistic, especially when considering how advanced they supposedly were compared to Vegapunk.
Nearly all civilizations Joy Boy came across would benefit from his arrival: However, some civilizations became bitter once they learned about this supposedly Great Kingdom who kept all resources and advancements to themselves while the outside world dealt with famine, disease, and war over limited resources: 20 of these nations would ally themselves to strip the Devils of their Utopia.
Some or all of the original 20 kings may have even started out as residents of the Great kingdom, residents who just like Joy Boy rejected the technological advancements of their homeland, but unlike Joy Boy took great pleasure in taking advantage of the underdeveloped nations of the outside world and would incense them to attack the Great Kingdom, all for their own greed.
Regardless, these 20 kings would weaponize this newfound technology and use it against the Great Kingdom: The latter never once imagined that their technology could be used in such a violent manner as they had never experienced conflict in their entire history – they were closed off the rest of the world after all.
However, they still managed to fight back thanks to their Devil Fruit powers. They would even gain the upper hand once Joy boy returned to protect his homeland. His adventures in the hostile “real” world gave him the combat experience to lead the defense against the allied powers.
The war came to its climax however, when the 20 kingdoms used the three ancient weapons to exploit the Devils’ greatest weakness: water. They sunk most of the world and the inhabitants of the Great Kingdom almost all perished as a result. Before being completely defeated however, the devils found a way to transmit their powers so that it would reappear organically in the world via plant-life for generations to come.
The few survivors of this kingdom would be enslaved, along with other races seen as inferior, and their descendants would be forced to carry the initial D. in their names so that they are easily identifiable to the World Government.
However, we now know that Queen Nefertari Lili adopted the initial, most likely out of guilt and as a form of solidarity with these descendants. Overtime the general population would come to forget the original meaning of the brand, and would begin to associate it with the will of the Devils who defied extinction.
The Government would come to regret not exterminating the bloodline right there and then, hence why they would become so obsessed with genocide and eradicating bloodlines such as Gold Roger’s in the future.
TLDR; The Great Kingdom was an advanced Utopia populated by Devil Fruit precursors; Joy Boy committed a grave sin by leaving to explore the rest of the world: As a result these outside nations allied themselves to annihilate the Kingdom.
Theory by Nightcrawler_DIO (https://www.reddit.com/user/Nightcrawler_DIO)