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...