"The sportive sunlight - feebly sportive, at best, in the predominant pensiveness of the day and scene- withdrew itself as they came nigh, and left the spots where it had danced the drearier, because they had hoped to find them bright."
The sun withdrew itself from the forest as Hester and Pearl walked in because Hester brought her own sin upon the scarlet letter into the forest. They hoped to find those spots with sunshine bright, but they became darker when they walked nearer.
"As she attempted to do so, the sunshine vanished; or, to judge from the bright expression that was dancing on Pearl's features, her mother could have fancied that the child had absorbed it into herself, and would give it forth again, with a gleam about her path, as they should plunge into some gloomier shade."
The sunshine vanished when Hester attempted to catch it for Pearl absorbed it into herself. Pearl is one of the most direct symbols of Hester's sin, but as a still innocent child, the nature gives her protection from the sin and of her innocence.
"She undid the clasp that fastened the scarlet letter, and, taking it from her bosom, threw it to a distance among the withered leaves... All at once, as with a sudden smile of heaven, forth burst the sunshine, pouring a very flood into the obscure forest."
Hester took off the scarlet letter "A" from her bosom, which means the sin was removed from her. Then the sun light spotted her, which symbolizes the sunshine only shines on the people who are innocent or pure.
From the sunshine's point of view...
When I see Hester with a scarlet letter "A" on her bosom coming into the forest, I perceive the presence of guilt and sin coming along. So I withdraw myself because I don't want to give brightness and delight to her. But look at that little girl, playing by herself near the lake, she is full of innocence and pureness, then I shift to the spot upon her. Wait, what just happened? The scarlet letter "A" is lying on the ground... Does Hester decide to get rid of her sin...?