Wait, what?
Laws exist to protect members of our society from the wrong doings of other members of society. If we take this out of context with morality than laws exist for no reason. Without morality with which to subject perceived wrong doings with, there would be no basis for a legal system at all.
How do you define morality?

Ok, im not disagreeing with you thats the way the legal SHOULD be, but is by no means the way the legal system IS.
The legal system can effectively be looked at as as kind of function, punishments given from certain circumstances. Imagine this:
C is the commited crime
L is the set of laws
Court is the fucntion of the legal system
the punishment a person receives is equal to: Court(C,L)
This is the legal system, this is how it operates, there is no need for morality here. You are correct in saying that "there is no basis for a legal system" but only in the legitamacy of this system. If someone has power over you and that persons says "dont do x or ill do y" there need not be any basis of any kind for that person to assert this rule over you.
Your line of thinking reminds heaps of some of the guys i had to study last year for philosophy of law. There was some guy, think it was dworkin, who said "any law which isnt a moral law isnt a law", or something there abouts. Point is, those guys lost favour with modern jurisprudence a long time ago, there are far more better takes on law then those. The philosophers who take the same line as you have good points but they dont address how the law actually works, they focus on how it should work, i cant stress this enough to you.
For much better explanations on how the legal system soveriegnty works look up Michel Foucault and Giorgio Agamben. For Focualt look up "Society must be defended" and "Security, Territory, Population: Lectures at College de France". For Agamben look up "The state of exception", "what is a camp?" and "Security and Terror".