This isn't my area, but I've heard that cooking is part of digestion.
I know evolutionary biology isn't as intuitive as people always assume, but theoretically this fits within my model - digestion burns precious calories (at least in a world with too many calories), breaking down the food using fire somewhat allows for the body to spend less calories on breaking it down itself. So our ancestors who used fire to cook had an advantage because they could spend less calories on digestion.
Archaeological evidence suggests that humans can control fire between 700,000 years ago and 120,000 years ago.
There's also a hypothesis that the nutritional changes allowed through cooking increased our brain size - https://en.wikipedia.org/wiki/Control_of_fire_by_early_human....
But fundamentally, I wonder if we cook too much. Some compounds are very fragile, and cooking would harm nutrition (as you said). As I said, not my field, but I try to stick to a lot of leafy greens as is recommended by health services, and the occasional cooked proteins.