1980s or 1990s novel about a girl who fails a final test in school and meets up with other kids to learn how to survive by banding together. Eventually they get recruited to leave Earth and start humanity's chance at peace in an egg shaped space ship. I remember them leaving because the earth was over polluted and dying.
I'm unsure whether to post this as an answer as I don't remember all the details very well, and it's not a perfect match for the OP's description. But I think this might be An Invitation to the Game by Monica Hughes.
[A] girl who fails a final test at school [...]
The story does begin with her getting her exam results, but she has in fact passed with flying colours. Unfortunately, the rise of robots and automation mean there are too few jobs to go around, and she and the other kids are informed at the same time as they get their results that they have been unsuccessful in even getting admitted for job training.
[She] meets up with other kids to learn how to survive by banding together.
Yes — in a VR simulation of the planet they're being sent to. Though it's a bit clandestine and they aren't actually told they're going to be sent to colonize a planet.
Eventually they get recruited to leave Earth and start humanity's chance at peace in an egg shaped space ship.
I don't remember if the ship was egg-shaped. It was to start a new life on this planet. The human race wasn't at war so there was no need for a "chance at peace."
I remember them leaving because the earth was over polluted and dying.
In the book's background — yes, but robotics had enabled humanity to come through that and survive. Unfortunately, the economy was now addicted to the cheap, uncomplaining labour of robots and, as the main character ruefully reflected, it was easier for the human race to get rid of their young people than to get rid of the robots.