The arrangement as such is probably legal. Usually with these services, you become a contractor of them and they become a contractor of your client. Pretty straight forward. But it's not without problems and risks...
For one, it's not very scalable; neither vertically (more money per client) nor horizontally (more clients). It's fine so long as your client is OK signing an agreement with the middle-layer company and so long as your income doesn't stand out too much.
You also have potential problems around liability, data protection/privacy︀ laws, intellectual property, labor rights (which in some cases do apply for contractors), bonuses/perks, physical︁ access, physical equipment, and so on and so forth.