It's a vague enough concept that, even though some laws probably forbid something like it, you could probably implement something to get around those restrictions. For example, a law might cover the doing nothing option, but might not cover doing something boring or annoying. In fact, if they actually have you doing nothing, you might find a way to employ the time even if you do have to be present in a location, so doing something stupid might be more effective.
Many contracts are unclear about what exactly counts as an activity you're employed to do, but if it really came down to it, you could always find some boring and pointless thing that sounds like it's part of your job. So you're an IT person, normally administering servers? Well, cleaning out old keyboards could be a job function. Remember that we want to verify that the keyboards still function well for fast typing, so you have to press each key a hundred times and verify how many times it missed. Meanwhile, next door, a programmer is writing a program to intercept and count key presses and verify the machine-generated report against the human-entered report. A manager is one door down from that and has to have a meeting every time the reports differ to discuss why there are inaccuracies in the report. The company can argue that each of those people is doing something related to their job function that could have a beneficial effect on the company if they had to.
I feel guilty for coming up with that method. I hope nobody actually does it.