SSN may not be technically needed for marriage depending on where you live, but it is generally recommended to do it before marriage and ASAP. Sometimes local SSA offices consider a marriage to be a voiding of a K1 visa and therefore will not process an SSN after the marriage. If that happens, she will not be eligible to get an SSN again until she has her green card. Not having an SSN can complicate things such as opening a bank account or getting a driver's license. All of this is highly dependent on how things work out and where you live, but imo it's better to get the SSN first and not chance it.
Our timeline after husband's arrival was:
Arrive late at night, around 11pm, on June 16
June 17 - Checked online if the I-94 was updated with his K1 entry. It was, so we immediately went to the SSA office and applied for an SSN.
After 2 weeks, the card had not arrived, so we called and requested a new one to be sent. 2 weeks after that the card arrived and we had the number.
Mid July - The day the card arrived, we went to the courthouse and applied for a marriage license. Then at the courthouse scheduled a date with a judge to be married, which was a couple weeks out.
Used those couple of weeks to do the AOS paperwork and assemble packets.
August 1 - Got married.
August 2 - Added the marriage certificate to the packets and sent it out.
As you can see, even waiting for the SSN still had us very safely within our 90 days, especially since we leveraged our downtime to complete as much of the AOS paperwork as we could. I'm a big advocate for getting that number first because it will give your partner lots of doors for independence, which is really crucial - it is very tough moving to a new country and having to rely on someone else for EVERYTHING from transportation to finances, so the smaller that window can be, the better! In my state, we still had to wait for the EAD to be able to open bank accounts and get a driver's license, but we had the EAD by October, which was a much smaller window than waiting for the green card, which we still do not have.