Many of the tire manufacturers will show a wide range of compatible tire and rim widths that the tire will FIT on without failing - does not necessarily mean a particular configuration is ideal. As mentioned, rim width affects tread surface - too narrow and it makes the tread too round, reducing the contact patch. Same for too wide - makes the tread too flat so the tire rolls over past the tread surface on a steeper cornering angle.
On our motorbikes this was exacerbated when a narrower tire was fit on a wider rim - you could see the tire had no 'chicken strips' - the edge of the tread that appears when you lean a bike over - would disappear completely, thereby telling you your tire is reaching it's limit of contact.
This is less critical on a bicycle cuz we don't have the lean angles, but does come into play when reaching for maximum traction on the trail for a given tire set.
There is so other many factors here. These are good 'guidelines' to follow though but dont stress out over a few mm. You probably wont even notice unless you maintain your tires within 0.5psi.
Before wide rims were in vogue, it was common to put wider tires on narrower rims. Sure the profile wasnt perfect but everyone did it and we all survived just fine. The argument about having less contact patch for a rim that is too narrow could easily be changed by a psi reduction. Changing the roundness profile from ideal seems more likely. What is the ideal roundness profile? Depends on the tire and even the rider and conditions (I have always preferred a rounder profile tire) being more of a 'leaner than a 'stuffer'.
Wider rims really became more standard with the advent of tubeless as it gives the tire/rim interface more stability and would be less prone to burping. I experienced this back in the early 2000s and suffered an injury and bike damage from it. There are articles on this if anyone is interested.
When I was really into motorized sport bikes and pushing the cornering limits, I tried +1 tires on stock rims and it was scary when REALLY leaned over. The bike would tend to fall into the corner more and require corrections. I dont push my MTBs like this at all. I was lucky to get 2k miles out of a set of tires and always wore out the sides first
I find the advantage of a larger tire(on the same rim...within limits) always (for me) compensates for having a less than perfect profile. As an example on my Juiced CCX which saw mostly gravel rides. The rims were 19mm inner width (which was quite common in MTBs awhile back as all my old MTBs have this spec rim). The original 45c tires were not even useful for my intended use. I put on 2.1 tires F/R and liked this alot although about 5 times every ride I thought to myself, "wow, almost lost the front end there". Putting a 2.25 on the front solved that problem immediately and I never had these issues again. Was the profile perfect? Gosh no, you could see it. Did it matter? Nope (note that I ran 5psi lower due to bigger tire). Would a wider rim have worked better? Definately, it was an upgrade always on my mind, but why fix a problem that doesnt exist just to match some numbers on a list
Im all about using the correct combinations of tires/rims and using the widest rim possible but you can get away with quite alot of variance. Go over to mtbr.com and read all the stories. (I have).