The Barracks feature becomes available once your Stronghold has been upgraded to level 10. Once the Stronghold has been upgraded, you can start converting any building that is over level 5 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 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.