What was the original basis for separating kids from parents, per the law?
There's no systematic separation of 100% of all immigrants from their children, so there must be some sort of reason for doing it sometimes, even if it's a bad reason.
I'll explain briefly. Back in 2013 or so there was a lot of violence going on in El Salvador and Honduras, it was at least partially the US's fault for a variety of reasons I won't get into here but it involved the drug war and the usual meddling in the politics of central American countries.
Anyway, as a result of this there was a decided uptick in the number of actual unaccompanied minors reaching the border. Most of these children almost certainly qualify for some kind of asylum. But Obama's administration, in typical gringo fashion, decided to call this a national security crisis rather than a humanitarian crisis. In a 2014 interview Hillary Clinton said:
“We have to send a clear message, just because your child gets across the border, that doesn’t mean the child gets to stay. So, we don’t want to send a message that is contrary to our laws or will encourage more children to make that dangerous journey.”
This is almost identical to the rhetoric I'm seeing from Nazis about Trump's policies today, but we'll leave that aside for now. The situation with all these children and the Obama Administration response meant that lots of children were being incarcerated in detention centers (which are much more like concentration camps than like regular jail). I forget the exact circumstances but there was a court decision that basically said you cannot incarcerate the children in these facilities, that you had to find other accommodations for them, like a foster home or another family member or something like that.
So what's happening now is that in April Jeff Sessions issued an order that the US immigration enforcement apparatus is to incarcerate and prosecute everyone who is caught crossing the border illegally - this has never been the case in US history before, not even in the 1950s when "Operation Wetback" was an actual government program to round up the
braceros and deport them back to Mexico. And families are being separated as a result of this directive. There is no specific directive or order to separate families under some clearly-defined circumstances - rather, it's a combination of other policies, most importantly zero-tolerance for border entry, that produces this result.