when writing a backstory, you want to have 3 core elements.
- some sort of conflict
- some sort of explanation (why the villain is the villain and such.)
- and think, how does this fit into this story?
But, backstory can be extremely difficult to create.
and when you add it you have to be extremely careful. Unless your plan is to reveal everything, the villain's origin, purpose for evil, why they hate the main character, etc. And it's never wrong to add a few funny cliches every once and a while ;)
Now, there isn't much to be said about writing backstory, just know that you can never go wrong with planning out ahead of time, i learned that the hard way.
Backstory also depends on your characters family line, if some of them are related, it's important to add that into a backstory somehow, especially if it is between the villain and main hero/character.