As Daniel correctly observes, whether or not guessing is a good idea depends on the scoring system, more precisely whether you lose points for wrong answers or not. By doing a (very simple) assessment of your expected (point) value we can distinguish the following cases:
Case 1 - No point loss for wrong answers
This is the simple (and probably most common) case - a wrong answer is 0 points, same as not answering the question. It should be fairly obvious that in this exam design there is no reason not to guess. Quite frankly, if there is no punishment for guessing, you should always guess, independently of what else is going and or how much of an idea you have what the answer might be. You can only win.
Case 2 - Wrong answers lose some points
An alternative exam design is one where correct answers give a point, and wrong answers lead to some amount of point loss (either a full point or a fraction thereof). Not answering of course neither gains nor loses a point. Now it depends on how sure you are and how much you will lose if you are wrong:
Case 2.1 - Full point loss for wrong answers
In the most extreme (realistic) case, a right answer gives as many points as a wrong answer loses. Statistically speaking, it's ideal to guess here if and only if the probability to be right is >50%. So if you are quite, but not 100%, sure you should still take the answer. If you can narrow the options down to 2 but you don't know which it is, it's statistically speaking a wash if you pick one or skip the question. If you think three or more options could be right it's ideal not to pick any of them and move on.
Case 2.2 - Fractional point loss for wrong answers
If a wrong answer loses a fraction of the points that a right answer wins, you need to generalise a bit from Case 2.1. It's easiest to analyse this case by considering how many of the possible options you can exclude, and then assess your expected value of randomly guessing between the remaining options. For example, if there are four options, and you can exclude two of them, you really only have two plausible options left. When a wrong answer loses less points than a correct answer gives you, you should still guess. If you cannot exclude anything, you should probably not guess (under reasonable assumption about the test design).
Some further considerations:
If multiple answers are possible:
If multiple answers can be correct (e.g., answers A and C are correct, but not B and D) the same principles from above still apply, but the space of possible choices explodes to the product of all possible answers. If there is no point loss for wrong answers it's still always ideal to take a guess, but if a wrong answer loses points it becomes much more unlikely that guessing is ever really the right choice unless you are pretty sure you know what the right answer(s) are.
If "none of the above" is a possible option:
Statistically speaking "none of the above" is just one more option to consider in your analysis. That said, in practice this is a bit tricky since you will never be able to exclude this option unless you already know the correct answer for sure (and then you don't need this analysis). So if "none of the above" is a possible answer and wrong answers lose full points, you should only guess if you are pretty sure that one specific answer is right.
As a note for educators looking at this - you may read this answer and (correctly) conclude that the best way to disincentivize guessing is to subtract a full point for wrong answers, combined with having "none of the above" as a possible choice. While this is undoubtedly true, consider what the impact on students is who are not guessing, but who simply made an honest mistake. Essentially, this leads to the awkward situation where a partial but slightly incorrect solution is worse than knowing nothing and skipping a question entirely. If you intend your exam to be a measure of student knowledge, that's not what you want.
For exams with calculations, I found "none of the above" to be a particularly nefarious exam design - this prevents students who know in principle how to do the calculation from sanity-checking for simple calculation errors (did I arrive at one of the possible solutions?). In my opinion, the only reason to pick this design is if you want as many people as possible to do poorly, independently of how much they actually know.