The Barracks feature becomes available once your Stronghold has been upgraded to level 10. Once the Stronghold has been upgraded, you can start converting a building that is over level 5 and offers you the option to 'convert' to Barracks. Converting a building to a Barrack costs Iron. Once you have upgraded a building to Barracks, you can move your Barracks by converting any suitable building without a cost or loss of progress.
Barracks are used to upgrade Troops. Leveling up Troops behaves similarly to that of Heroes, meaning Barracks can also be used to get rid of any extra Troops you might have.