The concept directly comes from Roman law, and is concisely expressed in the brocard Ignorantia legis non excusat (ignorance of the law is not a justification).
The essential public character of a law requires that the law must be accessible by anyone in the territory of the jurisdiction on which the law has competence. Then, if effectively publicly accessible, the law HAS to be known by everyone, so that no one can ever try to justify his conduct as innocent because he was not aware of such a law/rule.
About the accessibility, usually a sort of convention exists (by some called "the essential preliminary rule") by which the laws are issued and rendered accessibile by methods, authors and means that are simple and well known: the law is readable in certain places (some systems prescribe that a collection of the laws is copied in every local city council), is made by certain authorities (usually sovereign, government, parliament, and derivative bodies), enters into effect in certain ways (many systems for instance prescribe a certain number of days - ofetn 15 - after the release). This is commonly intended as a constitutional regulation, and in fact many constitutions or statutes exactly describe the correct procedures.
However, most recent interpretations (also in consideration of the modern vastity of a legal corpus in western countries) tend to milden the extent of this concept, in the sense that in determined cases, when the difficulty of being informed of the existence of a law/rule is truly relevant, and in consideration of the average lifestyle of the average citizen, a certain impossibility of being informed of a regulation can be opposed, mostly in civil fields. On a penal side, the quality of the knowledge of the law is part of the evaluation that is developed about the animus nocendi or the mens rea, in the sense that certain subjective conditions can weaken the personal resposibility.
The theme was widely discussed, also for political reasons, at the times of the Enlightenment and in the 18th century, given the heavy proportion of illitterate citizens in European countries (for obvious reasons, an illitterate citizen would have some difficulties to be aware of all the laws in a country). It was then also said that both the presumed knowledge and the heavily increasing corpus of national legislations, were working in favour of lawyers, creating for them unprecedented additional professional opportunities.
Some debate was started in recent times in doctrine, when some authors proposed to consider this concept as an extension (or at least an analogy) of the other ancient concept (typical of criminal law) that no one can be punished if not depending on a law that was issued before the action was committed (non-retroactivity of the law). This interpretation is however deeply discussed, given that the matter would hyerarchically more properly refer to a constitutional doctrine rather than to a civil or penal one. Secondarily, the debate is focused on the capabilty of the citizen of being able to understand whether a certain behaviour is legally allowed or not, rather than on whether the verified behaviour was or not a crime (or however not allowed) at the moment it was committed.