I agree with all of the various factors people have mentioned. For me, it's kind of like pornography: I know it when I see it. Something like drywall I will never do again -- the guys who do it are *fast* and know what they're doing and generally do a much better job than I could in a much shorter time for a reasonable price. Something like tree removal I postpone and dither about because it costs a mint, but you need skill and specialized equipment, and it's dangerous if you don't do it right, so in the end I suck it up and pay. Same with anything else that involves major electrical or gas or roof, or that is physically pushing it. DH once tried to install a patio and threw out his back after two hours of digging. We hired out the rest of it the next day.
OTOH, the situations that really seem like paying a major premium to be lazy and avoid unpleasantness, I just can't do. We had some guys quote us $750 to trim our front hedges. Now, they're big and annoying, but seriously: $750??? For a couple of hours of work? For something that I'm going to need to repeat several times a year? We went to Home Depot, dropped $50 on an electric hedge trimmer, and haven't looked back.
The one thing I do NOT do is compare the cost of the job to my billing rate. I know it's a popular metric, and sure, it's useful for comparison, but really, that's a fair comparison only if I would actually be working instead of doing the project. Usually, the reality is that I'm not taking off work to do the project myself -- I'm doing the project in time I would otherwise be sitting on my ass earning nothing. Would it be economically more efficient if I used that time to grow my business and put in the work to bring in more money, while hiring out the project for a fraction of the price? Absolutely. But I'm not going to do that. If I hire it out, I'm going to use the time I freed up sitting on my ass. So in almost every case, doing the project myself is almost always a net benefit economically, because I'm converting unproductive time to productive time.
But that doesn't mean I do everything myself. Because the reality is the most precious thing I have right now is my downtime. Precisely because it is so limited. So I do often decide to hire things out, even though my labor is effectively free, because the cost to my time with my family and relaxing on my own is far too high. You also need to consider other costs that may be associated with the project. Sure, I can spend all day Sunday doing something on my own. But Sunday is my day to get the grocery shopping and meal prep for the week done. So if I save a couple hundred bucks DIYing something, but we then end up eating a bunch of takeout because I didn't have time/energy to get my normal food chores done, then it may not be a net win.
YMMV, of course. Everyone's weighing of the various factors is going to be different. I'm thinking sort of like the engineer's triangle, except with money, free time, and the project -- pick two.