as was already posted, they appear near a city only if there is enough space around and only in tiles which you've discovered. This makes sense otherwise map would get flooded with barbarians. I've had games where throughout the game not a single barbarian spawned.
Update: I mentioned that land barbarian uprisings occur only in tiles that have already been discovered/revealed. I should point out that it does not matter which civ discovered the tiles. So you can have uprising near your town in squares that you have not yet revealed, but other civs have.
the most common spawns are cavalry which are later replaced by musketeers (the replacement happened at 1800 AD in one of my games, but I cannot confirm if something else triggered this)
some combinations I've seen: 6 cavalry+legion, 2 cavalry+leader, 8 cavalry, 4 cavalry+leader, 4 cavalry+2 chariots+leader (yes, chariots are a thing), 3 cavalry+leader, 4 cavalry+1 chariot+leader, 2 musketeers+leader, 4 musketeers+4 cannons+leader, 4 musketeers+2 cannons+leader, 6 musketeers+3 cannons+leader. There are probably more combinations, but this needs to be researched. Also I have not seen knights spawning on land.
musketeers & cavalry pillage irrigation but not roads. Cannons, knights, leader, legion do not pillage. Not sure about the chariots.
the spawns seem to be 4/5/6 tiles away (can also be diagonally) from a city
unrests will not happen if you place a unit nearby
it's hard to determine the frequency of these unrests. Seems to be a random thing. In 2 games the first unrests started at 2720 BC and 2560 BC. As much as 27 turns and as little as 3 turns can take place between unrests in the same place.
while land spawning barbarians always seem to target a particular objective (city), barbarians from ships can get lost and just wander around the map aimlessly
regarding fleeing leaders (diplomats), you've noticed they disappear if you don't catch them soon enough. In some games they can stay in tiles indefinitely. Enemy AI just ignores them.
Update: I'm having difficulties finding out what triggers transition from cavalry --> musketeers on land uprisings. Unlike sea spawns these do not happen regularly. But still on my last playthrough first musketeers I noticed spawned after I researched steel. However I doubt this is the cause.
Logic by observation explained by axx here: https://forums.civfanatics.com/threads/barbarians-spawn-logic.630389/#post-15096489
Copy from the forum thread: