What it means
It means doing something risky when the chances of it backfiring are right there in your face. You say it when someone's pushing their luck, messing with a bad idea, or carrying on with something that could blow up and leave them scorched.
Usage examples
"Lending him money again? You're playing with fire, mate, he still hasn't paid back the last lot."
"Lending him money again is playing with fire, you know he never pays back."
"Skipping the safety checks to save time is playing with fire on a site like this."
"You're texting your ex while your girl's sat right there? Nah, that's playing with fire."
"He kept chatting back to the manager in front of everyone. Proper playing with fire, that."
Where it comes from
This one comes straight from the old literal image of handling fire and getting burned if you misjudge it. That picture has been in English for ages, and the figurative use grew naturally from it. By the 1800s, people were already using it for risky behaviour that could turn nasty fast.