I understand that praying optional prayers in congregation is not allowed. But then why do we have Eid prayers in congregation since it is, in any case, optional until the return of Imam Mahdi (AJ)?
Eid Prayer is allowed to be prayed in congregation because it is in its original form an obligatory prayer in the presence of the Prophet (SAWA) and the Imam (AS). It is not like Salat Al-Lay or Nafila or Ghofaila etc which is always recommended. The reason behind praying Eid Namaz in congregation is its original form which is Wajib.
Wassalam.