Murder mysteries - or almost any kind of mystery - is one of the common things adventures go into when it's not just combat or saving kingdoms from possessed demons. This is also one of the places where you can get into trouble. In a book or movie, you can make sure that the right clues are found and things are strung together at the right time for maximum climactic achievement. In an RPG that's a lot harder. After all, you have 4-6 other people working on the adventure, putting clues together, and they - unlike the protagonists in a novel - know the mind of the person crafting the mystery and what they tend to do. That said, there are still things you can do. So let's go into it.
First, Key Evidence Should Never Rely On Chance To Find
The Gumshoe RPG makes one of the smartest moves an RPG could make regarding mysteries with one simple mechanical change: there are no rolls to find the key clues to a mystery. This is something worth bringing into whatever system you have. Is a clue is absolutely crucial to the successful resolution of the mystery, it should not be left up to chance in order to find.
Instead, what I like to do is give the key evidence when the PCs look with the right skill - and I suggest skills based on the scenario - and then have the roll be for additional information. So the murder weapon, for example, is always going to be found. Evidence about what kind of weapon it is, what that could mean, etc, etc is extra that I give out with the roll. The key evidence is found. Helper information is found with the roll. The better the roll, the more information they get.
Second, Knowing And Proving Who Did It Should Be Two Different Things
Your players may figure out the mystery before you are ready for them. That's fine. Players in RPGs tend to be people who like solving puzzles - it is part of the appeal of TTRPGs even if you don't normally use puzzles. However, knowing who did it and being able to prove it should be two different things. So even if they know, can they prove it? Sure, they may go the direct route once they are locked in, but that's fine. Just give reason for them to not go too hard until they have the key proof needed.
Third, Leave Yourself Outs. Multiple potential "who done its" is best.
One of the key pieces of advice for writing a murder mystery is to have several suspects who all could legitimately have done the deed. Evidence should never point to just one suspect. Instead having evidence that implicates multiple suspects is better. The solution can then be found by finding the one person that all the evidence applies to. Even then it can be good to have all the evidence point to multiple people. This can be helpful in sewing doubt until you're ready - after all you can collapse to multiple people if you really need to - and it can help you use the mystery again for a different group and even if you have player overlap, the mystery can point to a different criminal just to keep folks guessing.
Fourth, Avoid Red Herrings
Red herrings are common in mystery fiction to help throw people off the trail. They're bits of evidence that seem important, and can be used to keep the reader from getting the right killer too fast or to pad out the story because they have to be discredited. THey work great for this in books and fiction. They work less well in RPGs. In general I'd suggest avoiding them, or if you have to use them then make sure you have other evidence that clearly points to them being not relevant if they're investigated. Mostly I'd recommend avoiding them. Once you're comfortable running mysteries you can break this rule. Just make sure you understand it first.