Carlson’s primary effect on the ending is mainly a symbolic one.
Earlier in the story, Carlson shot Candy’s dog, putting it “out of its misery” and saving the men at the bunk house from having to smell the dog all the time. The act was carried out for the greater good of the men on the ranch, and it was justified, yet Candy was powerfully affected by the death of this dog.
Killing the dog was an unfortunate necessity carried out by Carlson, who had little connection to the dog. Candy realizes that he should have been the one to shoot his dog if someone had to do it. The act would have, ostensibly, had more mercy that way.
This situation relates to the end of the story when Lennie is shot by George. George could have let Carlson or Curley shoot Lennie, but he chose to do it himself, correcting the mistake Candy made earlier and making Lennie’s death more merciful.
We can look at Carlson's impact on the ending of the story in another way as well. His line at the close of the book can be seen as part of the commentary Steinbeck makes about the harshness of the world as described in Of Mice and Men.
Upon seeing Slim and George sadly walk off for a drink after George has shot Lennie, Carlson says, "Now what the hell ya suppose is eatin' them two guys?"
Here, Carlson is representative of a world that does not recognize human suffering and the value of human emotions.