Apparently on the theory, “If an audience will swallow this joke or yarn it won’t gag on anything,” gag developed, some hundred and fifty years ago, as an improbable story, some tale or yarn taxing the credulity of the listener, or, eventually, a joke that would bring forth hearty laughs from the hearers.
In the theatrical world the gag was likely to be a line or so of his own inserted into his part, usually to evoke a laugh.
He was the original gagman.
But, especially when radio began to make heavy demands upon the wit of professional humorists, the capacities of others were needed in the promotion of laugh-producing mirth.
Then the writers of humorous lines, rather than the speakers, became the gagmen.