Yes! In the times of our ancestors, begging was a legitimate occupation! Thanks to an act of the Scottish Parliament, March 22, 1425 which declared:
"Also it is ordained that no beggar be suffered to thig or beg either in burghs or in the land between fourteen and seventy years of age, unless it is seen by the council of the town that they cannot make their living in other ways. And they that are so found shall have a token from the sheriff in the land, and from the aldermen and bailies in the burghs, and that under pain of burning on the cheek and banishing from the country."
Photo by Ray Oaks (Own work) [CC BY-SA 3.0
(http://creativecommons.org/licenses/by-sa/3.0)]
via Wikimedia Commons
In essence, people who were found to be fit enough to work, but unable to find work, were given a token by the sheriff, bailies or alderman, which allowed them to legally beg for money. This meant that they could not be arrested or prosecuted for being a vagrant. It allowed the beggars the freedom to beg for money, wares or food and to do so without worry of retribution from the law enforcers of the day. Often, the tokens would have the name of the parish or burgh stamped on it. This showed the parish that was responsible for the beggar (and to where a body might need to be returned if anything untoward happened to him/her). The beggar could go anywhere within the burgh or parish stamped on their token, but could not be seen to beg in any other parish, or they could, in fact, be subject to arrest and prosecution.
Some tokens would state "Pass and Re-pass" which gave the beggar the freedom to freely wander from burgh to burgh (market town to market town) and to beg beyond the confines of their home parish/burgh.
Of note, is that the beggars HAD to be of able body and capable of work. This differentiated them from the elderly or infirm, who were more likely to require, and be in receipt of, poor relief either from the church or heritor (pre-1845) or from the burgh (post 1845).
If your ancestor is listed as a "beggar" in the Scottish documents, they you may be able to consult the local burgh archives to see if you can find out any more information and the particulars about how they were granted their beggar badge and given the right to beg for a living.
The Records of the Parliaments of Scotland to 1707, K.M. Brown et al eds (St Andrews, 2007-2016), 1425/3/22.