Why is it illegal to give your opinion/advice about a legal problem or
case if you are not licensed or do not have a lawyer/client contract?
The official "reason" is consistently articulated by U.S. courts:
Protection of the members of the lay public of our State, when they
seek legal advice — and that is what defendant purported to furnish —
is the basis of the requirements of licensing of attorneys by the
State, and this protection must be deemed to embrace whatever kind of
law or legal rights the layman seeks advice on
The reasonable protection of those rights, as well as the property of
those served, requires that the persons providing such services be
licensed members of the legal profession
And all of this with but one purpose in view and that to protect the
public from ignorance, inexperience and unscrupulousness
Again, that is the "official" answer or "reason".
However, it is naive to pretend that through licensed membership effectively protects the public from ignorance, inexperience and unscrupulousness. Lawyers will give me downvotes for saying this, but many instances of legal malpractice and incompetence are not duly sanctioned, let alone reversed. Oftentimes a layman just wants to be done with his legal troubles, and therefore he will not even report any unscrupulous lawyer(s) who got involved in his matter. The public knows that, and so do the lawyers.
Furthermore, nowadays legislative provisions, rules of procedure, court decisions, and law journals are available online for free. Thus, a person who is not functionally illiterate has the ability to verify the accuracy of the "advice" provided to him. Becoming well-versed in legal doctrines and hermeneutics does not happen overnight, but it is definitely more feasible than members of the legal "profession" are willing to admit.
The ulterior motive is as pointed out in the last sentence of Greendrake's answer. The legal "profession" becomes less profitable if more people become knowledgeable enough to prescind of a lawyer. An informed, verifiable advice on the person's problem can provide that person a starting point toward prescinding from attorneys, or at least give him elements with which to filter out some incompetent ones.