I've wondered this question before too, but in the context of playing poker for free on Zynga where people do this all the time which is a little different from a tournament but much of the same basic reasoning applies.
People who appear to just randomly go all in before the flop either don't know what they're doing or they know what they're doing and are baiting you with good cards which is probably the less likely of the two possibilities.
To make a good decision, first, you need to get a sense of what your probability of winning is. There is a table summarizing your approximate probability of winning heads up on this article on Wikipedia:
If you have the top pair and are playing against a lower pair or one or two undercards, you have a pretty high probability of winning of somewhere between 70-84%. This is probably extremely likely if you have AA, KK, or QQ. If you're playing regular or free poker and not a tournament, you probably should take these bets since your probability of winning is so high. If you're in a tournament, you need to decide whether that 1/6-1/3 probability of getting knocked out is worth doubling up.
If you have a low pair or middle-low cards, your probability of winning is at best only a little better than 50%, and so unless you want to gamble, the decision to fold is very easy, especially given that you're asking about the context of a tournament where you only get a prize if you make it to the end. I tend to tell myself in this situation, even if I have the best hand, do I want to take a really big bet where my probability of winning is only roughly 50%? If so, then my long term poker performance will become dominated by the few big bets I take where my probability of winning is only 50% and I'll be wasting my money on mediocre bets.
The difficult situation is where don't have a pair but have two cards that are relatively high and maybe even suited. If your opponent has a pocket pair, the decision to fold is easy as you are notably less than 50% to win the hand, but even if you're up against an opponent who doesn't know what they're doing, you probably have to give them credit on an all in bet in a tournament where they put in the effort to enter for at least one really high card like an A or a K and maybe even two high cards, like two face cards. This puts you in a situation where your probability of winning is somewhere in the 40-60% range, and once again, you probably don't want to waste your money on a big bet where the odds are only mediocre.
One final important thing to consider in these situations is the possibility of someone else entering the pot. Even if you have AA, your probability of winning when a third person enters the pot drops to about 66% and a fourth person makes it only a little better than 50%. So this is getting into the trouble range where you very well may be risking getting eliminated from the tournament, although if you win you're in really great shape to stay in for a longer time. In a regular game this is the situation you dream of because the pot odds are excellent.
Above all, stay level headed in these types of situations. Don't let it upset you. Don't start thinking that just because you are a better poker player than this person that random chance will respect you. Be patient. Poker requires lots of waiting, and you want to be betting lots of your money when your odds are good, not when someone who doesn't know what they're doing gets you to play a mediocre hand. General advice in several poker books I've read is that when playing against people who aren't good players, you need to play tighter and just be ready to show down good cards. The player who doesn't know what they're doing will make a lot of calls that they shouldn't, and you want to be in a pot with them when you have a really good hand, not when you're tossing a coin.