Complex sentence: These caves were witness to a series of invasions in the surrounding areas by different rulers and each time the caves were used for a different reason, sometimes even for things like housing by the armies or sometimes by refugees.
Split into simpler sentences: These caves were witness to a series of invasions in the surrounding areas by different rulers. Over time the caves were used for a different reason, sometimes even for things like housing by the armies or by refugees.