All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
Your husband does not have the right to ask you whether or not you had an affair prior to marriage, and you are not obliged to inform him of that. Rather, it is impermissible for you to inform him of them because it is incumbent on you, along with repentance, to conceal your sins. The Prophet said: “Whoever commits any of this filth (abominable sins) should conceal himself (i.e., should not reveal his sins and make them known to people) just like Allah, The Exalted, concealed him (i.e., concealed his sins from others and did not expose him).” [Al-Hakim and Al-Bayhaqi]
Lying to him in this case is permissible, but it would have been better if you resorted to Tawriyah (i.e. to say something which has more than one meaning and intend a meaning different from what the listener is likely to understand). One of the relevant reported quote from one of the companions reads: “Tawriyah is a safe way to avoid lying.”
The basic assumption is that you are clear of the sin of communicating with any man in the past. Therefore, it is impermissible (for him) to accuse you of it without supportive evidence. The Sharee‘ah forbids negative assumptions; Allah, The Exalted, Says (what means): {O you who have believed, avoid much [negative] assumption. Indeed, some assumption is sin.} [Quran 49: 12] You should avoid anything that may make you a target of such accusations by getting rid of all traces of such relationships. ‘Umar said: “Whoever exposes himself to suspicion, let him blame none but himself.” [Al-Bayhaqi in Shu‘ab Al-Eemaan]
All problems should be solved away from divorce, especially since you have been blessed with a child. We advise your husband’s family to be rational and let their intervention be for the sake of reconciliation. It is easy to opt for divorce, but it is often difficult to bear its consequences.
If divorce does take place, there is no blame on you if you waive your right to custody, unless you are obligated to undertake it (for some reason). This is because custody is a right for the mother and not an obligation on her, so she may give up this right. However, this is restricted to the case when relinquishing her right to custody does not incur harm on the child. If it does, then it is impermissible for her to waive her right to it. If your right to custody is waived, it is transferred to the next female relative who is worthy of it, like your mother, for instance, according to the sequence mentioned by jurists.
The father is eligible for custody if he meets the conditions mentioned by jurists, including having a female fit to care for the child, whether a wife or a Mahram (permanently unmarriageable kin) relative. In the event of dispute, you should refer it to the competent entities responsible for settling the disputes of the Muslims.
Allah knows best.