In "For Anne Gregory", the speaker mentions God to emphasise that no human being can truly love a person for their inner self or soul alone. The young man argues that only God can see beyond physical appearance — the yellow hair — and love someone for who they truly are on the inside. This is proven when an old religious man found it written in a book that only God could love someone for themselves and not for their outer beauty.
The examiner expects three things here: (1) the contrast between human love (based on appearance) and divine love (based on the soul), (2) the reference to the "old religious man" and the "book", and (3) the conclusion that God alone loves unconditionally. Avoid retelling the whole poem — focus on why God is mentioned and what point it proves.