The role of the government:(Short definition)
Pave the roads,
deliver the mail,
collect the taxes,
defend the shores.
The only one they can do with any certainty is the third one.
The Posse Comitatus Act forbids the military to participate in domestic law enforcement.
There may be argument that illegal immigration is tantamount to "invasion."
However, as written by James Madison in The Federalist: the military was for "security against foreign danger,...."
1
While certainly a problem, I do not believe that illegal immigration constitutes "foreign danger," which my interpretation would mean attack by a foreign military or by a sovereign nation.
Immigration and Naturalization, Customs and Border Patrol do not fall under the Department of Defense. Activities by these organizations are subsequently domestic law enforcement issues.
1 Preventing a Reign of Terror