We cannot understand the nature and basis - much less the proper scope - of religious liberty unless we have some idea of what religion is, and why it is worth protecting people's right freely to believe and practice it.
What is religion?
In its fullest and most robust sense, religion is being in right relation to the divine - the more than merely human sources, if there be such, of meaning and value.
Of course, even the greatest among us in the things of the spirit fall short of perfection in various ways. But in the ideal, the person would understand as comprehensively and deeply as possible the body of truths about spiritual things, and would fully order one's life, and share in the life of a community of faith, in line with those truths. In the perfect realization of the good of religion, one would achieve the relationship that the divine - say God himself, assuming the truth of monotheism - wishes us to have with him.
Different traditions of faith have different views of what constitutes religion in its fullest and most robust sense. There are different doctrines, different scriptures, different structures of authority, and different ideas of what is true about spiritual things and what it means to be in proper relationship to the sources of meaning and value that different traditions understand as divinity.
For my part, I believe that reason has a very large role to play for each of us in deciding where spiritual truth most robustly is to be found. And by reason here, I mean not only our capacity for moral discernment, but also our capacities for understanding and evaluating claims of all sorts: logical, historical, scientific, and so forth.
But one need not agree with me about this in order to affirm with me that there is a distinct basic human good of religion - a good that is uniquely architectonic in shaping one's pursuit of and participation in all the basic human goods. One begins to realize and participate in this good from the start of one's quest to understand the more-than-human sources of meaning and value and to live authentically by ordering life in line with one's best judgments of the truth in religious matters.
The existential raising of religious questions, the honest identification of answers, and, within the bounds of justice, the fulfilling of what one sincerely believes to be one's duties in the light of those answers, are all aspects of the integral fulfillment - the flourishing - of human beings as rational creatures. But if that is true, then respect for a person's well-being, or more simply respect for the person, demands respect for one's flourishing as a seeker of truth and as a person who lives in line with one's best judgments of what is true in spiritual matters.
That, in turn, requires respect for liberty in the religious quest - the quest to understand religious truth and order one's life in line with it.
As all the great thinkers in the Western tradition of reflection on religious liberty have observed, a coerced "faith" is not really faith at all. Someone can be forced to manifest outward signs of belief, but believing itself - having faith - is an internal act of reason and will. Such an act is not amenable to coercion. To attempt to compel it is to undermine the very possibility of its being performed. Because faith of any type, including religious faith, cannot be authentic - it cannot be faith - unless it is free, respect for the person - that is to say, respect for an individual's dignity as a free and rational creature - requires respect for religious liberty.
That is why it makes sense, from the point of view of reason, and not merely from the point of view of the revealed teaching of a particular faith - though many faiths proclaim the right to religious freedom on theological and not merely philosophical grounds - to understand religious freedom as a fundamental human right.
Interestingly and tragically, in times past and even in some places today, regard for persons' spiritual well-being has been the premise, and motivating factor, for denying religious liberty or conceiving of it in a cramped and restricted way. The error here was not in the premise: Religion, as I have defined it, is indeed a great human good and the truer the religion, the better for the fulfillment of the believer. The error, rather, was in the supposition made by some that the good of religion was not being advanced or participated in at all outside the context of the one true faith (whatever one regards that as being), and that the good of religion could be reliably protected and advanced by placing civil restrictions enforceable by agencies of the state on the advocacy of heretical ideas.
In rejecting this supposition, we need not embrace the fallacious idea that error has rights. What we are recognizing is that people have rights, and they have rights even when they are in error. And among those rights, integral to authentic religion as a fundamental and irreducible aspect of human well-being and fulfillment, is the right to express, advocate, and, within the broad limits of justice and the requirements of the common good, act in line with one's conscientious beliefs about spiritual matters. This is true even if one's beliefs are, in one way or another, less than fully sound, and, indeed, even if they are in error.