Sam Dawson (Sean Penn), a man with a developmental disability, is the single father of Lucy (Dakota Fanning), following their abandonment by her mother, who is revealed to be a homeless woman who "just needed a place to sleep". Despite his limitations, Sam is well-adjusted and has a supportive group of friends with developmental disabilities, as well as a kind, agoraphobic neighbor Annie (Dianne Wiest) who takes care of Lucy when Sam cannot. Though Sam provides a loving and caring environment for precocious Lucy, she soon surpasses his mental ability. Other children tease her for having a "retard" as a father, and she becomes too embarrassed to accept that she is more intellectually advanced than Sam.
On the advice of his friends, Sam approaches a high-powered lawyer, Rita Harrison (Michelle Pfeiffer), whose brusque manner, fast-paced schedule and difficult personal life have earned her a reputation as cold and unfeeling. In an attempt to prove to others that she is not heartless, Rita surprisingly agrees to take on Sam's case pro bono. As they work together to secure Sam's parental rights, Sam unwittingly helps Rita with her family problems, including encouraging her to leave her philandering husband and repairing her fractious relationship with her son. She and Sam have an emotional moment together when they reveal that they never feel good enough.
At the trial, Sam breaks down after opposing counsel convinces him that he is not capable of being a father. After the trial, Lucy resides in a foster home with Randy Carpenter (Laura Dern), but tries to convince Sam to help her run away, and continually escapes in the middle of the night to go to Sam's apartment, whereupon he immediately returns her. Ultimately, the foster family decide not to adopt her like they initially planned. They decide to return her to Sam, with an arrangement that Randy will help him raise her.
The final scene depicts a soccer game, which Sam referees and in which Lucy participates as a player. In attendance are the foster family, Sam's friendship group, and a newly single Rita with her son.

Question: What arrangement allows Lucy to return to Sam?
Answer: Randy agrees to help raise her.
Alternative answer: randy will help him raise her