The sentence is badly written. The it refers back to an impersonal (and unexpressed) subject: '[it is] necessary'. What the sentence means is "Apes can stand up if necessary, and it would [indeed] have been [necessary] for females [carrying] babies." This amount of ellipsis is a hindrance to communication, although some writers think it's clever.
Apart from being badly written, I think this is untrue (as I believe I've seen film of young apes clinging to their mothers' backs) - but that's a bit off the point .
Student or Learner