Nier.automata.game.of.the.yorha.edition-codex.p... Page

The androids' support pods (042 and 153) gain consciousness and refuse to delete the protagonists' data. Through a collective effort of the player and the community, the pods reconstruct 2B, 9S, and A2, giving them a chance to live in a world free from the cycle of war—provided they don't repeat the same mistakes.

The androids were given a fake god (humanity) to fight for so they wouldn't lose the will to live. NieR.Automata.Game.of.the.YoRHa.Edition-CODEX.p...

For more details on the deep lore and character backstories, you can explore the NieR:Automata Wiki . The androids' support pods (042 and 153) gain