Exams are meant as a fair testing ground for the potential of someone. You cannot cheat them. You get the same questions, and the same amount of time, as everyone else. How well you do is representative of how well you know that subject.
If you get really stressed about them and don't do well, that is also kinda the point. Getting really stressed on the job and not doing well is not something an employer wants. You will need to be able to work well under stress as well as normally.
Not having enough time is also the point. If it takes you 3 hours to complete an exam, you do deserve to do worse than someone that took 1 hour, even if they got 10% less than you in the way of marks. Say you're a doctor and there's a patient in critical care. You need to be able to act fast and do what you need to, rather than spending a lot of time determining what you should do. You should really be able to tell quickly, and get it done. The ideal student would be one that gets it done quickly and accurately, and exams do alright at testing this.
Where exams fail, however, is in keeping up with modern times. Are you allowed Google in an exam? No. Why not?
In a job, if you need to figure out what the cosine rule is to do something, you're not going to sit there and go "Well I'm fucked, I can't remember back to 3 years ago when I learned it". You're going to go "Shit... Um, Google, what's the Cosine Rule?", and get the answer and use it.
It also still tests merit and potential. Those who know the course will spend less time on Google finding answers, and more time answering questions. Make the exam out of practical examples rather than theoretical ones [I.E, for maths, put in an actual application of the mathematical principle that someone would use it for, rather than just saying "Find the derivative of 4x^2+3x+1". I.E: More worded questions. For some reason people hate them, I love them, and they are better questions for showing an understanding of the concept than the questions that just tell you what formula to use and see if you can remember it and substitute in some numbers]. It works off the same principle as the time limit, in that those who know it don't spend as much time figuring it out there and then, finish more of the exam, and get a higher mark. Those who don't know it spend more time figuring it out in the exam, answer less questions, and get a lower mark.
It also gives an advantage to those who are good at using the resources around them and quickly sourcing information, as they can figure the stuff out quickly and answer a number of questions even if they're not entirely sure of the work.
Really, the whole concept of school and that is IMO flawed, but there's not a lot of better ways to do things sadly so... IDK. Maybe one day education will receive the revolution it needs.