These words, which can be nouns or verbs, are unrelated in their most common meanings.
A rifle (noun) is a kind of long-gun, such as used in war and hunting. Riffle, in contrast, is usually a verb for the action of flipping through a stack of papers or cards—when a person uses their thumb to separate the cards quickly, and let them come back together, one after another.
Though they have different meanings, these words might be related in origin (no one knows for sure). The defining quality of a rifle (gun) is that it has a rifled barrel. The barrel is the long tube. A rifled barrel has grooves spiraling along the inside, giving spin to the bullet, which makes the gun more accurate at distances. The word rifled comes from an old French word meaning to make a groove.
And rifle is also a verb meaning “to search through things quickly and roughly” such as when stealing from someone.
So, it may be that riffle is related to rifle—and riffle may possibly be a blend of ruffle and ripple. In any case, all of these words influence the way we understand the others.
Now, riffle also has other meanings besides “the motion used to shuffle a deck of cards.” It can also describe the similar motion of grasses, leaves, or the surface of water, caused by a gentle wind. As a noun, riffle can describe the small ripples that arise on the surface of water in the wind, and other things with similar shapes—i.e. anything with a series of small ridges or grooves in it, such as the inside of a rifle barrel, or ridges of sand or rocks under the water (which causes riffling on the water). And riffle can also be used for the sound made by riffling water, or leaves, etc.