It is obligatory to straighten the rows and make them complete (by filling any gaps) when praying
Question

                The Messenger of Allah (blessings and peace of Allah be upon him) said: “Whoever connects a row, Allah will connect him (with His mercy)”. But in the Eid prayer place we see that one row may have more than one gap in it that have sufficient room for more than three worshippers. What is the ruling on leaving these gaps without filling them?
Praise be to Allah.
      It is obligatory to make the rows 
      straight in prayer. That has been discussed previously in the answer to 
      question no. 36881. There is no difference in this 
      regard between Eid prayer and other prayers. 

    Part of this straightening is completing 
    the rows and connecting them, and not leaving gaps between worshippers. Abu 
    Dawood (666) narrated from ‘Abdullah ibn ‘Umar (may Allah be pleased with 
    him) that the Messenger of Allah (blessings and peace of Allah be upon him) 
    said: “Straighten the rows, stand shoulder to shoulder and fill the gaps; be 
    gentle with their hands of your brothers, and do not leave gaps for the 
    Shaytaan. Whoever connects a row, Allah will connect him (with His mercy), 
    and whoever breaks a row, Allah will cut him off (from His mercy).” 
    

    Classed as saheeh by al-Albaani 

    Muslim (430) narrated that Jaabir ibn 
    Samurah (may Allah be pleased with him) said: The Messenger of Allah 
    (blessings and peace of Allah be upon him) came out to us and said: “Why do 
    you not make your rows as the angels make their rows in the presence of 
    their Lord?” We said: O Messenger of Allah, how do the angels make their 
    rows in the presence of their Lord? He said: “They complete the first rows 
    and they make the rows compact.” 

    Abu Dawood (671) and an-Nasaa’i (818) 
    narrated from Anas ibn Maalik (may Allah be pleased with him) that the 
    Messenger of Allah (blessings and peace of Allah be upon him) said: “Fill up 
    the first rows, then the next ones, and if there is any deficiency, let it 
    be in the last row.”

    Classed as saheeh by al-Albaani in 
    Saheeh Abi Dawood and elsewhere. 

    Al-Baaji (may Allah have mercy on him) 
    said:

    It is obligatory to complete the first 
    row, then the next, and if there is any deficiency in should be in the last 
    row.

    End quote from al-Muntaqa Sharh al-Muwatta’ 
    (1/386) 

    It says in al-Mawsoo‘ah al-Fiqhiyyah 
    (27/36): 

    Part of straightening the rows is 
    completing the first row, then the next row; it is not prescribed to start 
    the second row until after the first row has been completed, and so on. This 
    is a matter concerning which the fuqaha’ are agreed. 

    Based on that, no one should stand in a 
    row when in front of him there is another row that is deficient or in which 
    there is a gap; rather he should push through the rows to fill a gap in the 
    rows in front of him. End quote. 

    Shaykh Ibn Baaz (may Allah have mercy on 
    him) was asked: 

    If there is a gap in a row during Taraweeh 
    or qiyaam because some of the worshippers have left, should the imam ask 
    those in the second row to complete the first row? 

    He replied: 

    It is obligatory for the members of the 
    congregation in an obligatory or naafil prayer to complete the first row, 
    then the next, because the Prophet (blessings and peace of Allah be upon 
    him) enjoined and encouraged that, as he (blessings and peace of Allah be 
    upon him) said: “Make your rows straight and fill the gaps.” And he 
    (blessings and peace of Allah be upon him) said: “Why do you not make your 
    rows as the angels make their rows in the presence of their Lord?” They 
    said: O Messenger of Allah, how do the angels make their rows in the 
    presence of their Lord? He (blessings and peace of Allah be upon him) said: 
    “They complete the first rows and they make the rows compact.” 

    End quote from Majmoo‘ Fataawa Ibn Baaz 
    (30/124-125) 

    Shaykh Ibn ‘Uthaymeen (may Allah have 
    mercy on him) said: 

    It is prescribed for the imams to ask the 
    people to straighten the rows in Eid prayer and prayer for rain (istisqa’) 
    as it is in other prayers, because if the people are not reminded of that, 
    they may become heedless concerning it. It is prescribed in every 
    congregational prayer, if the people are forming rows, to remind them and 
    tell them to make their rows straight. End quote. 

    Liqa’ al-Baab al-Maftooh 
    (46/9) 

    He also said: 

    Many imams and many worshippers are 
    careless about the matter of making the rows compact, so you will find a row 
    in which there are many gaps that no one fills. This is a mistake, because 
    the Prophet (blessings and peace of Allah be upon him) instructed the people 
    to make the rows compact, and said that the angels before Allah, may He be 
    glorified and exalted, make their rows compact. End quote.

    Fataawa Noor ‘ala ad-Darb 
    by Ibn ‘Uthaymeen (111/161) 

    If the people pray with a gap in the row, 
    they have done wrong, but their prayer is still valid. 

    Al-Haafiz Ibn Hajar (may Allah have mercy 
    on him) said: 

    Although we say that straightening the 
    rows is obligatory, the prayer of one who does not do that and does not 
    straighten the row is still valid. End quote. 

    Fath al-Baari 
    (2/210) 

    And Allah knows best.