I haven't written a lot of mysteries, but I've read and watched a ton of them. How to write a good mystery?
It's really important to know where you're going. For me, I start with the end. Who did it and why? How did they do it? Who will they try to frame? How will they be caught?
From there, you work backwards. Figure out how they got to this ending.
Then you add the red herrings. The persons with motives and or opportunity who really didn't commit the murder. Often these will be criminals themselves with something real to hide, a reason for lying to the police or the inspector. You need at least 5 of these to have a good compelling mystery. It's less interesting unless you have a plethora of suspects.
A mystery needs to be solvable, so you need to provide sufficient clues that a discerning reader will be able to solve the mystery, but it can't be obvious, what is often called sign posting. Ideally if you do it right, something about the case of the red herring suspects will not quite align like the actual killer's does, and if the reader gets this, they will have a genuine sense of satisfaction in being able to solve your mystery.
Lastly, you need an interesting setting, but more importantly one you can make come alive. We writers tend to write what we know. Ideally you like to write about a place you've been, but it certainly needs to be a place that excites you the writer.
You do all this successfully and you should have a good mystery. I did this with my book The Christie's - A Christmas Murder 1984. I intend to do it successfully again with Murder in the Amazon.
I shall probably continue to do it as long as I am motivated and enjoy it.