I love writing lore! I actually find I only really start coming up with lore after I have most of my story figured out (At that point I know the ins and outs of the world for the most part)
I honestly write lore for myself because I find it entertaining. I usually ask myself "how did this happen?" and "what is the story behind this?" And I know my characters so well that it just feels like I'm knowing more about their life.
Like for me, my current comic, The Commune has the characters living in a cult commune in the middle of the woods. I can tell you how they get their food, what the original purpose of the building was, how said commune was found by the leader and how the cult members began joining the cult.
Is all of this necessary to understand the comic? Nah. (some is) There is absolutely lore that I explore in the story because it is important and quite interesting, but you won't catch me making a chapter on how food production works there 
For me, the more unimportant lore is used in my extras, which I usually plan based on what chapter it will be posted after. While the lore is optional, I feel like it adds to the reading experience of people who enjoy learning more about the characters and world and for me it lets me expand on smaller parts of the story.