Having a synopsis for your book is very handy. It is a tool you can use for a variety of purposes. A good synopsis written before you get started can help you complete the writing of your manuscript. And a synopsis is not set in stone. It is not the bible on which you have sworn the lives of your children. If your story changes you can adjust it accordingly. And once the manuscript is done you can use the synopsis to help pitch/talk about your story, find a publisher and promote your story. If nothing else it is a handy dandy summary of your story that demonstrates to yourself and others that you have an appropriate structure, that there is a coherent plot, underlying themes, that your key characters have realistic motivations and challenges, and that you have a satisfying ending. Writing a synopsis can show you where there might be gaps or problems with your plot so you can go back and fix them before you submit your manuscript to a publisher.
A synopsis needs to summarise your story. Ideally it also conveys something of the voice and tone of your work.
Follow the direction of the story in the order in which you have written it and summarise it as neatly as you can. Each chapter might become one to three sentences? A synopsis should also help the editor/publisher/judge answer a series of questions. What kind of story is it? (Horror, lit fic, crime, romance, magic realism, sci fi etc...) Who is/are your main character(s) and where is the story set? What is the problem to be solved, the goal to be achieved by the main character(s) or the great question at the heart of the story? And what is at stake if they don't solve or achieve or answer it? What steps do(es) the main character(s) take to solve or achieve their problem/goal and what stands in their way. What do they obtain and/or learn along the way and which key folk assist them? How is the problem solved or the goal achieved or the question answered? To what do our hero(es) return? Does your synopsis do this?
You should include the ending of your story. It might feel like a spoiler but an editor/publisher wants to see at first glance that your story is a cohesive whole with a satisfying denouement. You might want to save the 'ending' for when they read the manuscript but they may not read the manuscript if they think the novel is without a good ending. Reading a full manuscript is a big investment of time. When I see a synopsis with the ending/conclusion/solution left off I wonder if the author is hedging their bets, or hasn't been sure which way to go or has been unable to end their story. If it's just that they don't know how to write a synopsis, a publisher won't know this. And they might assume the former is true.
You don't want background or why you wrote your story in your synopsis. The synopsis is a summary of your story, in the style in which you have written it. Nothing more and nothing less. You need enough detail so the summary makes sense, but not so much that it ends up looking more like your manuscript than a brief run down of events. Some publishing houses want your summary to be 300 words or less. Others are happy with two pages (or sometimes more). If they want a synopsis included with your submission they will tell you what form it needs to take. Summarise your story and include the flavour of your telling of it. That is all.