All this "Riker just stayed XO for 15 years and was scared or wasn't good enough to be captain" is crap. I am going to have to stand up for Riker here, even if I like Kirk better. We all know the real reason he stayed XO all those years is because that is how he was written. But If you look at Riker and TNG as a whole, it does make sense to me that Riker stayed XO all those years.
People are forgetting that 23rd Century VS 24th Century Captains, indeed command structures, were a lot different.
You can make the argument that being a captain is less exciting in the 24th century, than the 23rd. While I am sure Kirk was an atypical example of a captain, based on appearances of other ship captains on TOS, it still seemed routine for a captain to beam down on an away team on a regular basis.
In the 24th century, it was uncommon for a captain to beam down on an away team. With few exceptions (IE Picard, Sisko, Janeway), in the 24th century, the captains place is on the bridge, and the captain rarely gets to go on away teams. In fact, Riker felt it was his job to ensure the captain stayed on the bridge, while the first officer took the risk of going on an away team. Of course Picard over ruled him from time to time, and could do it if he wanted to, it seems rare for a captain to leave the bridge of the ship in the 24th century.
In the 24th century, captains were more diplomatic, and less brash than their 23rd century counterparts, mainly because the galaxy is more explored and star fleet is more established. There isn't the same amount of need for "cowboy diplomacy" in the 24th century.
So, you can make the argument that if you are an officer in your prime of your life (IE your mid 20s to mid 40s), and like going on away missions and adventures, but still need to work on your diplomacy skills (something that can take years for many people), maybe you DON'T want to be captain right away. It seems to me that people who make captain at a young age in the 24th century are doing it because they want to make admiral at a young age, but aren't very adventurous and just dream of being a beaurocrat (IE Admiral Nechayev), then yeah, you grab the first captaincy you can get, even if it is a garbage scow. But if you are an adventurer, and an explorer, then you spend more time as an XO (like Riker), and refuse promotion to admiral (like Picard).
Also, we see that in the Picard command structure, Riker seems almost a co-captain in many respects, anyway. Picard makes the final call on the big, potentially quadrant affecting decisions (or episodes that require him to be at the forefront of the episode), but much of the time, it really is Riker running the ship, and not just as an XO. Riker only has to answer to one man, and that is Picard, who is basically the 24th century equivalent to Kirk.
Not to mention, this is the Enterprise he is the XO for. It is the flag ship. He basically has the best of both worlds (no pun intended), where he can still go on away teams, and take active roles OFF ship, but also is running the Enterprise, when Picard isn't. So, I think to Riker, it is better to be second in command of the Flag ship, serving under a living legend, than to be captain of some Oberth Class ship, on some scientific mission to study spores on a Class L planet on the outer rim of the Alpha quadrant.
Not to mention Riker is very good friends with the command staff, especially Troi. That was his family, for all intents and purposes, and also, maybe after having left Troi to serve on the Hood, and then happens to be stationed with Troi on the Enterprise, you know he had to have thought, at least subconsciously, it was a second chance to rekindle things with Troi, which they ultimately did.
So I can see why it would appeal to Riker to want to stay as XO on the Enterprise.