Giles/Riley is an incredibly easy pairing to justify. You just need an entirely different show, actors, characters...and voila! viola! vole!
Yes, Giles and Riley go together like whiskey and milk, like peppermint and lemon. Mmmm, peppermon...*choke*.
In all seriousness, if we can pretend to be within a hundred miles of seriousness, you would have to scrap canonical Riley/Buffy entirely. Buffy starts college and launches into a series of romantic mishaps--Parker, some other one-date wonder, and then Riley, but with a twist. She discovers almost immediately that he's a commando, draws him into the Scooby club, shows him off to Giles. Riley is fascinated to learn about the council of watchers and when he reports back to his superiors at the Initiative about the whole slayer-watcher institution, he's appointed as liaison between the U.S. government and the council. For their part, the council turns out to be unexpectedly--even suspiciously?--keen to establish diplomatic working ties with the Yanks. They appoint their own liaison in Giles, who finds himself thrust into a new role he never anticipated, a prestigious and influential role. Just when he was feeling useless as an ex-watcher, he's got this cool new *thing*.
Buffy crushes on Riley for an episode or three, deciding that this is the *one*. Like her, he's fighting the good fight against evil, and yet he's got that whole clean-cut, wholesome thing going on; he's Joe Normal and she's a smitten kitten. She confides girlishly in Willow and they bend their heads together and plot how to rope Riley in, which even in the planning stages is a fait accompli, because how could he not fall for her Buffy charms? Pfft. That'd be crazy talk. They were made for each other, Willow says. Romantic heroes and partners in the struggle against tyranny! Like Ilsa and Victor Laszlo in Casablanca, except with demons instead of Nazis! Don't you mean Ilsa and Rick, Buffy asks dubiously. Ilsa left with Victor, Willow points out, unwittingly revealing a lot about herself to bemused fans by this casual choice of Victor over Rick. But Rick was her true love, Buffy says. I think you're over-analyzing, Willow says kindly. Besides, *you're* Victor. Buffy blinks. I am? Oh.
What she hasn't been noticing is how Giles has been getting a life of his own, and Riley seems to be lurking at its edges. When she comes over to Giles's apartment one night and walks in, she finds Giles relaxed on the couch playing his guitar in a mellow way, Riley sitting across from him in a chair, listening, and they're drinking and they look so comfortable with each other--when did that happen? Giles stops playing when she appears and it's a weird, awkward moment that Buffy brushes off as quickly as she can, because it simply does not compute. She asks Riley out in front of Giles, and doesn't see the tiny look they exchange, but Giles draws away silently to fix himself another drink as Buffy chatteringly dominates a conversation with Riley, despite little clues of discomfort and politeness he gives off. He turns her down very very kindly and she's confused.
This type of relationshippy stuff draws out for a few more episodes, subordinated to energetic A-plots, and then we get an episode like "Hush." Unknown to Buffy or any of the other Scoobies, Giles and Riley have, casually offscreen, started up a physical relationship, and it's only in this episode that Buffy finds out--she turns up at Giles's in the middle of the night after discovering herself to be mute, and he answers the door in his robe and pajama bottoms and his face is sharp and tense, as he's of course also just realized himself to be mute. And Buffy comes in with Willow, and they're both anxious, and Giles steps back and then Buffy sees Riley, standing there in the living room at three a.m., wearing sweatpants or maybe blue jeans, but nothing else--or he's just putting on his shirt.
She's absolutely shocked. And none of them can *say* anything to explain it, and that'd be the beauty of this twist, because the audience is forced to accept it; it just *is*. There's no room in the plot for the expected confrontational blather--shock! outrage! explain yourselves! No Gilesy stammering, except in silent pantomime. It looks natural, them being there, though. Or it will, in time, to fans who eventually rewatch the episode ten times and who are finally, a season or two later, able to work through their own issues and nod and say knowingly, yes, it makes perfect sense.
After this alternate "Hush" (which ends with Giles and Buffy sitting in his living room, unable to find anything to say to each other), the inevitable, difficult conversation is had. Riley is gay. Giles has been alone for a long time, recovering from his grief over Jenny with no outlet for his feelings, not even friends; alone in Sunnydale, he's been needing someone in his quiet way, and he isn't going to apologize for it, though he's of course sorry for the misunderstanding--her misplaced feelings for Riley. Buffy is embarrassed; she also realizes that Giles has never really shared any of his private life with her, and that she's been okay with that compartmentalization until this.
After a period of tension similar to the whole Oz/Xander/Willow/Cordy thing back in S2, Buffy and Giles re-establish their rapport and trust in each other, and Buffy lets go of her Riley crush and focuses her attention on someone else--Xander, maybe, or some new plot-foddery guy who ends out the season.
Riley, of course, dies at the end of season four in a tragic smelting accident.
No, no--not really. More likely, Riley just leaves Sunnydale for some reason or another, probably in season five, and Giles is forced to deal with another bout of unhappy solitude in the wake of his departure, though perhaps it's an amicable split and not as devastating as Jenny's death.
And then we leave this alternate universe and re-enter the normal canon timeline and the world ends in a rain of frogs, just as it did in mid-season five.