In "She Dwelt Among the Untrodden Ways" William Wordsworth is communicating three main ideas: Lucy is a relatively unknown person, Lucy is beautiful, and Lucy means a lot to the speaker.
The line "A violet by the mossy stone/half hidden from the eye!" helps express all three of these ideas.
It shows that Lucy is not part of mainstream life in that she is probably obscured by where she lives, in the way that the violet is probably obscured by the mossy stone. The words "half hidden" express that idea in a more obvious way.
It also shows how beautiful Lucy is in the eye of the speaker. Notice that she is metaphorically linked to a violet, which is a beautiful flower. Wordsworth could have compared her to a more common flower, like a daisy, which one would expect to find just about anywhere. But Lucy is uncommonly beautiful to him, so he compares her to something you don't see everyday.