As a whole, it's always important to factor exercise in to any weight loss journey. Particularly resistance exercise. It is certainly--unequivocally--true that the number one factor in any weight loss success is diet. Any good trainer, nutritionist, etc. is clearly going to tell you that 90% of the work people have to do when losing weight is changing a person's relationship with food. If you're serious about weight loss, everything has to be on the table concerning food and up for change. From changing your perceptions ("I don't like 'green' vegetables.") to your emotional needs ("Food comforts me.") to your emotional responses ("Food is there for me when no one loves me because I'm fat.")
That said, weight loss should be a 100% commitment, and if that last 10% is exercise, you still need to be onboard for the full journey. Just as much effort and dedication should be displayed in the gym as at the dinner table.
I know it's often an unpopular sentiment, but at its heart weight loss really is calories in and calories out. Calories in is pretty easy. That's food. Your body is a system and it needs energy. So the food you ingest is either stored (as lean mass or body fat) or burned as energy (via metabolic processes). Calories out is a little more complicated. We often think of calories out as straight up exercise, but it's really everything our body needs to function. This is where conditions like hypothyroidism come in (though the rate of hypothyroidism is very low and you should never assume such without consulting your doctor). While the amount of calories you burn via exercise is largely under the sway of physics (and despite best arguments to the contrary, no one can defy thermodynamics), the amount of calories you burn in internal processes can vary widely between two people. The shitty part for certain individuals is that those internal processes are most of the calories a person burns.
So what does that mean? When it comes to conditions like hypothyroidism, for most people, even overweight people, it means nothing because only 3% of the population is impacted while over a third of Americans are obese. "Consult your doctor regularly when undertaking a weight loss journey." The rest of it means prolonged weight loss plateaus are basically a function of calorie in/out equilibrium that must be mastered by some combination of adjustment between calories ingested and calories burned. And this is why exercise matters. Initially, a fat person has something in their favor: they are fat and just by virtue of maintaining their fat stores must consume a large amount of calories every day. Their bodies are, for lack of tact, calorie burning machines from the onset. So a good diet will have quick results. However, it's a game of diminishing returns. The more weight you lose, the fewer calories you burn as metabolic activities slow. It becomes a cycle as the body adjusts your metabolism down in response to its reduced caloric need. And extreme calorie restriction accelerates that response.
But there is a bit of a key point in there. I said you lose weight. Not just body fat, but weight. Let's take a 300 lb. 5'11 man with 40% body fat. With a BMI of 41.8 he's obese. He's carrying around 120 pounds of body fat. But he's also carrying around 180 pounds of lean mass. In an ideal world, if he were to slim down to 6% body fat, he would be 192 lbs. 12 pounds of body fat and still 180 pounds of lean mass. He'd also be pretty damn muscular. But this is not an ideal world, and as you shed fat you also shed lean mass. Shedding lean mass is a key component of what slows the metabolism quite drastically. Thus why exercise is so important. It serves two fundamental functions: resistance exercise is a great way to minimize loss of lean mass and aerobic exercise is a great way to keep metabolism high. And it's much easier to have that ship on course from the onset. If you wait until your first real plateau, the damage to your metabolism is done and far harder to undo.
Which brings me to another point. Assuming you aren't abusing anabolic steroids, gaining lean mass is very hard. Gaining lean mass is harder than losing weight. Gaining lean mass without gaining body fat is ridiculously difficult (and why it's generally done in successive bulk/cut cycles). As you exercise on the way down, you really won't have a very high likelihood of "gaining muscle" while still losing fat. That's more of a psychological comfort to people who have a bad week than general truth. Most people just simply cannot--will not--gain more than 1.5-2 lb. of lean mass a month even when trying. 15 lb. of muscle mass a year would be realistic for someone trying to gain muscle. Compare that to the 52 pounds or more that a person might reasonably expect to lose in weight in a year. So did you lose a pound of fat but gain a pound of muscle? Probably not. Don't fall into that trap. Re-evaluate your diet and exercise at each plateau. But what can you do when lean mass matters so much? An obese person has another thing on their side: over years of gaining weight their body had to put on the muscle to move all that weight around. So don't worry about gaining muscle mass--you're just trying to keep as much of the mass you have as possible on the way down. And as I've already pointed out, exercise is a big key to doing just that.
Obnoxiously, of course, that means that just paying attention to cutting down your calories isn't ultimately enough. You need a good macronutrient spread on the way down to make sure your body constantly has the right balance of nutrients to ensure it can repair and replace muscle and bone while shedding fat. To really have success, you need to think just as much about "building" muscle as "losing" fat. You need to think of food as fuel and fuel your body for what you need it to do! (Hence why I'm hugely not a fan of weight loss foods like Weight Watchers and Special K with their range of "low calorie sweets" with no value beyond just replacing a bad comfort food with one that's slightly less bad.)
Note for those of you considering options beyond diet and exercise... this is actually a bigger concern for people who have had some sort of weight loss procedure done. Gastric bypass in particular wrecks havoc on your lean mass because your body cannot get enough protein and the rate of initial weight loss is extraordinary. It's even worse on those who gain the weight back after these procedures, particularly women, because as the fat is packed back on the muscle can't return quickly enough to compensate. It's basically like declaring nuclear war on your metabolism as your body fat rockets up to 50% or greater of your body weight. Once you go down the road of gastric bypass, an inability to adopt a healthy lifestyle immediately can mean a year or two of weight loss followed by a lifetime of obesity. Sadly, what should only be considered a last resort for someone so obese they are on their death bed is quite often used as a shortcut to weight loss with nasty, nasty consequences.