Rory was an eternal soldier because he got sucked into the crack and was erased from time and space, so he never existed and nobody remembered him.
He came back as a soldier because the Nestene (alien race - robots made of plastic or something) create themselves based on a memory. The roman soldiers were from a book Amy had as a child and Rory came back because she had unconscious deeply buried memories of him (because ~love~ or something). He then killed her by instinct because he was a robot, and not Rory.
The doctor said that the box had magical healing powers (because you can't escape the ultimate prison even by death), so Amy was trapped in the box for 2000 years and Rory waited because he was made of plastic and couldn't age or die and didn't need to eat or drink or anything. He could have been zapped into the future with the Doctor's time travel but he thought Amy would be safer if he guarded the box.
During these 2000 years he became a legend, but once they got into the 1940s and he thought people might be suspicious he stopped dressing as a soldier and got a job at the museum as a security guard instead.
When they opened the box and let Amy out, she was healed. Then the doctor rebooted the universe by flying the box into the exploding TARDIS, and suddenly Amy is normal (With parents, which she never had before nor do we ever see again) and Rory is human and not plastic. The catch? The doctor ceases to exist. Except somehow he's magically brought back by Amy on her wedding day.