The team had her stay close to Joel, to avoid being viewed by players as a burden.
Ellie becomes traumatized and withdrawn after an encounter in which she is assaulted and nearly murdered by a band of cannibals, forcing her to hack their leader David to death with a machete.
Druckmann felt that moths' obsession with light mirrored Ellie's obsession throughout the game, as well as giving her a reminder of Joel.