The Stronghold protects your units from enemy attacks (e.g. they will not be wounded by an attack). When you put units in the keep they will not be stationed on the wall, but will participate in the courtyard battle. Each level will have capacity for more units.

Cost for Stronghold
Level Rubies cost Units protected
1175 wood & 130 stone 20
23,011 wood & 4,218 stone 50
315,000 150
424,500 300
537,000 500