It seems to me that RE has three aspects - two of which are legitimate in schools that are publicly funded and one of which is not.
It is necessary, first, for all children to be acquainted with religions and non-religious views of life (the plural being emphasised). This acquaintance should be factual and should, ideally, be taught from a scrupulously neutral standpoint.
The second aspect of the matter is that pupils should be taught to evaluate the actual effects the various religions and non-religions have in the world. This is part of a study of cultures in their historical (including current historical) contexts. This side of things should also be taught from a conscientiously neutral standpoint.
Both the above have a necessary place in the publicly-funded education of all pupils. The third aspect is the attempted persuasion that a given religion or non-religion is 'true' and the practice of ritual observances to reinforce that persuasion. That third aspect has, I suggest, no place in state-funded education and has no particular connection with the proper inculcation of the simple ethical standards that are necessarily common to people of different life-stances. I say this because the public is very diverse and the beliefs of minorities should not be pressed, at public expense, upon all children. There are four million or so adults in Scotland; the largest church has only about three quarters of a million acknowledged adherents and all religions put together muster only about a million and a half. Most people manage their lives in a decent common sense fashion with no more than a vestigial belief that there may be a god 'out there somewhere'; to be on the safe side, they profess such belief. These non-praying members of the human club are closet humanists; I suspect that many churchgoers are truly 'Monday to Saturday humanists'. (I prefer this term to 'Sunday Christians' - it is kinder and more accurate and, in my book, more cheerful). The persuasion and observance aspect of religion should be the public business of the churches and the private business of families and of individuals. Freedom to be religious in any of a variety of ways (a freedom that I defend to the utmost) is abused when a captive audience of innocent children is indoctrinated by minority enthusiasts let loose in state schools at the taxpayers' expense. Such licence is bad for pupils and, probably, bad in the long run for religion itself.