Why against the law? Agents are registered as bookmakers and as far as I know most of them are registered in off-shore countries. It is rarely against the law of the off-shore country to operate as a sportsbook.
It is not against the law of the offshore country but against the law of the countries where they offer their services. Normally agents are the way for bookies to take bets from countries where officially they don't / can't offer betting services (remember not long ago Pinnacle agents were arrested in USA although officially Pinnacle doesn't accept US players) so the bookies will always deny any relation to keep their hands clean.