To give a very eli5 answer:
People come together and build cities for various reasons. Maybe they trade with other cities or civilisations, or they’re close to something like water, gold or good farmland.
Sometimes, these things change. A river dries up, or the gold runs out, or their trade stops (maybe the other cities start using ships instead, and going around the city instead of through it!).
When this happens, the reason for being in the city ends, and bit-by-bit, people just leave and move to other places. Sometimes this happens so fast that they just leave the buildings behind.
There are “ghost towns” in America which are like this, where this only happened within the last ~200 years; now they’re just a collection of buildings with no-one living there, and in a thousand years, they’ll still be like that.
Ancient abandoned cities are pretty much the same.
Peruvian here, Macchu picchu was a ceremonial city for the Incas. Due to the complex access to it (jungle between Spanish and place) seems like it was never found. However local people knew about it. In 1912 Hiram Brigham discovered this and started to study the place.
Macchu picchu is not the only city, there are another ones that needs to be studied like Kuelap or even discovered. Lack of budget, access and data are why are not being discovered yet.
A city gets abandoned when the business that fed it before stops feeding it. No city grows its own food, so people need to earn money in some way to buy food from the country. If a city is supplied mainly by trading, a change of trade routes or a shift in prices can disrupt the trade and starve the city. If a city is supplied by crafts, obsolescence of said crafts will drive the city into decline. If a city is fed by mining, the exhaustion of mineral deposits or drastic lowering of demand for the local resource will make the city decline. In all cases, the jobs that formed the city’s society stop giving the citizens money, unemployment rises and people migrate from the city to some other place where they could live and work.
Environment change is a big one (drought, combined with other factors such as land exhaustion and constant warfare is often cited as the reason behind the fall of Classical Maya city states); Lop Nor is another – a “lost” trading city on the Silk Road that was abandoned at least partly due to change in the course of the river.
Ancient cities like Palmyra and Machu Picchu became abandoned and left in ruins over time because of a variety of reasons, such as natural disasters, war, famine, and political unrest.
Natural disasters such as earthquakes, floods, and volcanic eruptions were often the cause of cities being left in ruin, as they could cause significant destruction. War and political unrest could also lead to people abandoning their cities, as they may have felt unsafe or were forced to leave due to conflict. Famine could also lead to cities being abandoned, as people may have been unable to sustain themselves in the area.
Same reason we have abandoned (or dying out) cities today. Population gradually died off or moved out due to socio-economical reasons, destruction, changes in trade routes, etc. All a city needs to be abandoned is having a highway divert traffic, a railway become derelict, a mine getting closed, etc.
Latest Answers