I have edited your question as it contained two separate questions. You might want to post your question about the Ptolemaic Empire separately.
The first sack of Rome by Barbarians was by the Visigoths in 410 C.E., a mere 66 years before the abdication of the last Roman Emperor. Earlier, the Roman Emperor Valens had made a tactical mistake in allowing the Goths to cross the Rhine River in 376 C.E. to escape the oncoming Huns. Relations between the Goths and Romans were poor, and Valens himself was killed at the Battle of Adrianople shortly after the Goths crossed over. Once they had entered the Empire they remained. The Empire was too bloated in size and weak militarily to control them, and they often ravaged the countryside at will. The Visigoths, (probably a subgroup known as the Alimanni) approached Rome while fleeing the Huns. The wealth of Rome tempted him and the city was sacked in 410. Ominous as this may seem, one should remember that at this point, Rome was secondary in importance to Constantinople, the far wealthier city to the East. Although threatened by invasion from time to time, it withstood sacking until the Fourth Crusade many years later.
Rome was sacked again in 450 C.E. by the Vandals. Neither attack destroyed the city, but severely weakened it. To prevent an attack by Attila the Hun, the Romans paid huge amounts in tribute which further weakened the Empire. By the time the last Emperor abdicated in 476, the Empire was a shell of its former self.