Skirmishing units have existed in Europe and the world since ancient times. Light infantry units during the time of linear warfare is essentially an extension of that lineage. Originally, light infantry were units that had less/lighter equipment that would be more mobile than most core infantry formations in an army that would harass enemy formations. Harassing the enemy causes delays, they have to deal with their wounded, fill in gaps caused by casualties, etc. Light infantry units could get out before heavy units could react as they were often too slow or would rather keep cohesion in their formation.
In linear warfare, light infantry have the same basic role, with only a few differences. Since armor had become obsolete light infantry and regular units roughly carried the same weight in equipment so light units could effectively be pursued by other infantry. However, light infantry fought dispersed and could not effectively be engaged by musket fire. Even a well placed volley by traditional line infantry could only make a small dent in a unit of light infantry. On the downside, light infantry can't hold a line in melee. Tightly packed formations act like wedges into thinner lines and can quickly divide them, creating gaps that can be exploited by other units. To put it simply Light troops = better range capability; poor melee, Heavy troops: worse range; better melee. Both of these units need to be balanced and work together to provide optimal results.
The use of light units also can be attributed to some economic reasons. Typically an army in the 18th and 19th century was professional, made up of volunteers (I use the term volunteer loosely as impressing men into the military was common). As a result, bigger and taller men were preferred as they were often better in melee, the especially tall and large men would often be in elite heavy units such as Grenadiers or Guards. However, there is a large pool of shorter men willing to fight without quite making the cut for regular units. Shorter men could be put into units that specifically avoided melee, leaving all the big guys to be put in their optimal roles.