The Autobot plague victims are victims of the ancient Cybonic plague, a disease that was created during the Great War by Megatron himself. It's primary use was to infect the Autobots and wipe them all out. The only cure that could be found was with Megatron, who created the disease.
When Optimus Prime and Ratchet were investigating an Autobot distress signal, they found and entered a centuries-old crashed ship in hopes of finding any survivors inside. Instead they saw the deceased bodies of the ship's crew. After scanning their disease-ridden bodies, Ratchet concluded that they didn't die in the crash, but from an ancient virus known as the Cybonic Plague. When the ship moved, one of the victims' bodies, which hung from the ceiling, dripped infected energon. One of the drops of infected energon fell on Optimus' optic, causing him to be infected.
After that, they were left behind for medical cautionary measures.