Heat weakens the chemical bonds that form between adjacent polymer strands in clothes fibres. The weight of the iron forces them to adopt a new shape and when the heat is removed, the polymers rebond in their new position.
The trick with ironing is to set the heat so that it is just hot enough to disrupt the weaker cross-links, without damaging the bonds within the polymer chains