My coworker is struggling with a task. I know that if I do it, it will take about 40 hours. I estimate that at the current rate, it will take my coworker at least three times that. So the first argument for stepping in is efficiency.
The second argument is result quality. She got the task "per default", because it is part of a larger project she is responsible for. But the specific skills required for executing the task are mostly from the field I specialize in, and she lacks the knowledge and experience needed for it. My knowledge in her field is limited, but still sufficient for me to complete the task and achieve better results than she could, even though she gives her best.
The third argument for it is simple compassion. Doing it is hard for her, she struggles a lot only to end up with mediocre results, and this demotivates her. It has no benefits for her to go through it, she is not learning a skill she would need elsewhere. I could spare her the trouble, without suffering myself.
But there is also a good reason not to do it. Investing 40 hours in her task will endanger an important deadline I have, while she has no deadline for her task.
When I know I can do a task far better than a colleague, how can I evaluate whether or not to actually step in, or whether to let them struggle?