I am particularly interested in 19th Century drummer boys, but an explanation of their origin and role in previous eras would also be appreciated, if possible.
According to a preliminary search, the drums were also used as vital tools for battlefield communication but it sounds impractical in a scenario where cannons and gunfire are erupting, wheras other methods (flags and signals) wouldn't suffer from this caveat.
Well I can only comment on the British Army during the Napoleonic Wars but as that answers at least part of the question I shall proceed.
Firstly I shall draw the distinction between regimental bands and the enlisted musicians.
Regimental bands were non-combatants who were hired by regimental officers to accompany a battalion on campaign. They were not soldiers and did not frequently attend battles, however there are some examples where they did and either played music to lift the spirits of the men or helped to drag the wounded out of formation. These are not musicians you ask about in your question but I think it important to make note of their existence and what differentiates them from the enlisted men.
Now the first misconception is that not many of these drummers where actually boys. For example, at Waterloo the 2nd Battalion of the 73rd regiment of Foot had several drummers, the average age of which was 23 with the youngest being 17 and the oldest being 27. They had an average of 8 years of service each.
Aside from drumming these men had the duty of carrying out sentences of lashing. As such they were each expected to carry a cat-o'-nine tails in their packs. With particularly large sentences they would take turns of 25 lashes each.
In terms of the command and control element their use was rather limited. Orders were not issued exclusively through the use of drums. This is for a number of reasons, namely that it is entirely possible to not hear the drums over the din of battle; drums are not really eloquent enough to convey anything but the simplest of orders and in the unfortunate but fairly likely scenario that at least one company loses its drummer to enemy action it would be left without a serious method to issue orders.
Orders would be issued by officers and the drums would accompany them, for example advancing at the quick time would be accompanied by a drumbeat. However in this particular example it is important to note that the use of a drumbeat to teach or maintain the pace of marching was explicitly forbidden in the British army. As was the use of drums to dictate the movement of any formation Entirely because the men should be able to maintain the same pace as the men around them without relying on something like a drumbeat. For the reasons already mentioned.
Other things like assembling the men for roll call after bivouacking are not combat roles but are otherwise important. A few more examples would be form line or form column and the like. Again this was in addition to the orders and direction given by Sergeants and Officers. The most telling of all was an ominous continuous roll which indicated the most urgent order for a line battalion, that of forming square.
The primary objective of drummers in battalions though was that of assisting the wounded. Such is evident by their position at the very rear of the formation well behind the line. Aside from this they may be used to inspire or otherwise improve the morale of the men by playing music or marches, this was permitted whilst the formation was moving provided that cadence step was not required.
Sources:
The Waterloo Companion Mark Adkin
Weapons and Equipment of the Napoleonic Wars Philip J Haythornthwaite
British Napoleonic Infantry Tactics 1792-1815 Philip J Haythornthwaite
On a related note the use of Bugle calls by light infantry and rifle units is much more detailed, due to the nature of the role and the fact that these units were spread out over large areas combined with the better nature for the bugle for conveying orders (due to the distance the sound carried and the variation between calls being easier to distinguish) a much more advanced system existed however again the point is made that this should be to supplement verbal orders by officers and not to replace them.