As has been pointed out in the comments, there are lots of important reasons why we can't prevent electricity from working at all. The key, then, is to imagine ways of preventing humans from harnessing electricity. Trying to screw with electromagnetism is problematic - again, messes with ecology/biology, and could possibly be easily defeated by shielding.
A better bet is to deprive these humans of the material inputs necessary to create electricity. The most guaranteed way of accomplishing this is to put your humans in a setting where all metal only exists in trace amounts. This would make it basically impossible for humans to harness electricity in any meaningful way. "No metal" might be too limiting for you though: perhaps you want to eliminate electricity as a premise for some futurist samurai. In that case, you can probably get away with only eliminating the most conductive common metals: copper, silver, gold, aluminum, zinc. Any generator made with less conductive metal, like nickel or iron, is going to be be very very week. If someone did not know about electricity to begin with, they would have a really hard time discovering it using low conductivity metals. If the humans in your world already know that electricity can be harnessed, and that they are otherwise deprived of this ability, they might be able to rig something up using nickel wire, but it will be super limited and inefficient. If this is the case, say so in the comments below so I (or more likely someone else) can work on figuring out just how inefficient.
Note that whatever narrative device you use to eliminate technologically useful quantities of copper, silver, gold, aluminum, zinc (whether it be removing it from earth, or putting your humans on another planet), you will still need some trace amounts of copper and zinc, which are nutritionally essential to humans.