The law of unintended consequences has a long, rich history on TV — but the Showtime mockumentary “Reality Show” may get its own chapter.

The eight-week series — which Showtime has buried at 11:30 p.m. Thursday night — follows disgraced reality-TV producer Mickey Wagner as he attempts to make a showbiz comeback taping the lives of an ordinary family without their knowledge.

Wagner is a fictional character played by the show’s producer and writer Adam Rifkin.

Like “Get Smart” spoofed the ’60s secret agent movies or “Mary Hartman” made fun of the soaps, “Reality Show” was intended purely as a comedy about a reality-TV producer à la Mark Burnett.

But something about “Reality Show” has gone wrong — or right, depending on your point of view.

In each episode, flashback sequences show highlights of Wagner’s previous reality “hits,” including “American Imbecile” and “The Real Stripper Moms of South Beach.”

And now, other producers are interested in making real shows out of Rifkin’s made-up shows.

“We showed the clips to people after “Reality Show” was completed, to sort of say, ‘Isn’t it funny how we are lampooning what you do?’ ” he tells The Post.

“They, in turn, said, ‘You know, that actually could be a real show. If you are open to it, we are open to it.’”

Only in Hollywood.

Rifkin admits he’s had trouble getting Showtime to get behind his new comedy with promotion and a better time slot.

The premise of “Reality Show” is that Wagner — drummed out of TV by a scandalous mistake — must go to desperate, sneaky lengths to juice up an otherwise dull reality show.

But the stuff getting the attention is the incidental ads promoting made-up shows.

“It was really just supposed to be a joke,” Rifkin says.

Some of the spoofs are blatant rip-offs of more established reality brands.

“ ‘Blue Balls’ is a ‘Cops’ lampoon.” he says. “ ‘The Biggest Farmer’ is like ‘Biggest Loser’ — except they shed pounds by working it off tending the animals.”

The show idea that has gotten the most interest from outside producers, Rifkin says, is “Hobover” — a fake reality series that supposedly gives head-to-toe makeovers to bag ladies and homeless men.

And he’s not kidding about an actual version of the show perhaps showing up some day soon.

He expects to finalize a deal to sell the idea within the next few weeks — before someone else does it.

“I have been in Hollywood a long time and people will steal your stuff,” he says.

“So I would not be surprised if a hobo makeover show turned up somewhere else.”