The first game in the NieR: Automat series is loosely connected to a series called drakengard. Drakengard is set in a dark brooding fantasy world. In one of the endings of the first game, the main character and his dragon come to our world to fight a God called the mother beast. After the fight, the military shoot the main character and his dragon out of the sky. This event screws up our world because the ash of the destroyed mother beast releases an illness. Meanwhile, humans obtain the bodies of the dragon and that causes humans to be able to use magic in their research.

nier automata
via youtube

Catch up to the plot before playing NieR: Automata

There is more to this. But this is a backstory that is never really explained in detail. And doesn’t matter overall when it comes to the games. But that should give anyone the gist of how the world got to that state in the first place.

Lots of stuff happens that we are not going to spoil. But skip a few 1000 years later and suddenly humans seem to have reverted to a sort of medieval lifestyle. You play as a single dad taking care of his daughter in that time. But he stumbles on bigger events going on.
That is the first game.

The latest NieR: Automata is another few 1000 years into the future. And humans and technology seem to be back on its feet full force. This time the world is apparently getting screwed up by alien robotic lifeforms.

There is lots of lore to this universe. All very sad and depressing for the most part. Not a world you want to live in. But there are the drakengard and Nier games, there are novels and stage plays. So read them to catch up more.

Source: Vexoid