Armstrong was the mission commander, and Aldrin was the pilot for the lunar module Eagle. Due to the Eagle's design, the pilot's station was further from the hatch, so it was easiest for Armstrong to exit first. Aldrin mentions this in his autobiography Magnificent Desolation, and adds that he didn't mind going second at all.