Someone put part of their life into building those walls, and others into living there, and these relics are a connection to those lives. Perhaps even haunted by them--though I never noticed any ghosts.
There's mystery if we don't know the people who lived there, and old memories if we do.
We can fill the missing space with our own imagination, without any inconveniences like odors or beggars or unfriendly guards. What would they have been like? Can we tell what they loved from what remains?
We see the power of nature overwhelming human effort--which is either humbling or grand depending on how you feel about nature. (Or it's a testimony to high speed lead and high explosive--depends on the ruin.)
There's a reminder that sometimes something lasts past ourselves, even if it isn't the whole. We don't always get to choose which things are going to last.
We get a sense of how little our plans mean in the big picture. We do tend to take ourselves rather seriously, don't we?
They remind us of our own mortality and the failure of all our plans. It doesn't hurt (Ecclesiastes suggests we make it a priority) to remember that we're going to die.
They remind us that our own lives--right now--are generally ruins already, fragments of what ought to and might have been.