I wouldn't say that rifles were better per se than muskets, but for different applications -- speaking in terms of the American Revolution at least. Rifles look longer to load and could not take a bayonet, making riflemen extremely vulnerable, so riflemen were often paired with musket-armed light infantry for protection (with the Kentucky long rifle the load has to be whacked down the first part of the way with a starter, but the shorter, heavy Jaeger rifle used by the German mercenaries needs a mallet to hammer the load into the barrel -- not very practical). George Washington had a distaste for riflemen, and wanted to limit their numbers in the Continental army to no more than two regiments (pretty sure it's two). At the battle of Lexington and Concord, the number of colonists carrying rifles was probably close to, if not, zero -- many of them had rifles of course, but when going to fight they grabbed their muskets.
One for one the rifle is far more accurate, but from a strategic point of view it has some serious trade-offs.
From what I’ve read, the best rifle was the British Ferguson Rifle. some were taken off dead British soldiers at KING’S MOUNTAIN in which the riflemen from the hills out shot them.