Former Air Force here.
Seeing as how I worked in a training squadron for a few months as acting First Shirt -
You think basic training is a stressful mindgame? Wait until you are in real combat - you'll realize that basic training is a cakewalk in comparison.
The deal with basic being so mentally exhausting and somewhat humiliating is that it achieves a few main objectives:
1. You gain pride when you accomplish a task. In your head, you start going, "Yeah, I did it. Fuck you, Sergeant." Trust me, drill instructors know. They can see self-confidence start to form when you start doing things better and faster, just to show them up.
2. It eliminates a sense of independence among your platoon. Once everyone (well, almost everyone) is broken down to the basic element and treated the same, you start working together. I mean, teamwork makes everything EASIER, right? You gain some pride in your team as well, since you all came from the bottom to graduation.
3. It teaches attention to detail. It may seem like a pain in the ass to remake your bed in a certain way perfectly every day and hang all your uniforms in the same way. Or keep your foot locker organized in a particular way. And all the beds aligned, and boots underneath lined up. But think about this - when you do that, how much faster did you pick everything else up? You got in the mindset of paying attention to detail. Of course, no one gives a shit about that stuff out of training except on inspections in barracks.
4. It weeds out the people who don't have the patience or mindset for the military. When the shit hits the fan, you have to snap to your training in a heartbeat. If you can pass the tests in the end, you are probably never going to forget how to clear a barrier or move in formation quickly to another area instead of running around like headless chickens. It's funny - I know fresh recruits out of training at a glance because they don't walk on the grass and walk with their hands closed. It's good to fall into the old habits when it comes time to go to war.
5. It's tradition. If this shit was easy, you'd die in the field tomorrow. This ain't a cakewalk, son. Hold your chin up and be proud you made it through.
EDIT: I agree that some drill instructors are way out of their boundaries when training. You won't believe how many of these people keep getting called to the post to be warned about their insane, cruel methods. Ever wonder why some drill instructors never last or old ones eventually get replaced? Because they tend to push the limit too often and get bounced back to regular duty due to their big mouths and chuckle-headed ideas.