Cities get tougher the higher level they are, which makes it harder for other players to attack them thanks to city walls. You can also move troops on your cities to help defend it against incoming attacks, troops have an easier time defending higher level cities. Furthermore you can invest in the Guardian skill which increases your troop’s effectiveness when defending.