From Kansas State Historical Quarterly is an article on Cowboy Ballads and says this: "The Texas Ranger," another ballad of the trail, is of the familiar "Come, all ye" pattern. It introduces an incident that is a reminder of the fact that the cowboys were useful to the on-coming settlers in repelling Indian attacks and in pushing the frontier westward.
The words of this song are recorded by Louise Pound, Mellinger Henry, John A. Lomax, and others, but the tunes seem to be rare. Of the version here recorded, both words and music were contributed by N. P. Power, Lawrence, February 18, 1938. He set the song down from memory as he heard it in 1876, while a cowboy on the John Hitson cattle ranch, eighteen miles north of Deer Trail, Colo. Mr. Power says that he has never seen the song in print and has no knowledge of the author. His version is much the earliest that I have found.
They also have a link to music at Texas Rangers Sheet Music