Phase transitions and superconductivity of iron-based superconductors from first-principles