This is one of the more clear cut examples of a flaw in the TNG script, and is akin to 'The Wesley Problem'. From a Universe perspective, an officer's rank and the command structure of a ship are two separate (but often similar) things. Each position (2nd in command, third in command, Chief Engineer etc) has a recommended rank for the role, but officers can be promoted above (and actually be below)this rank if the situation allows for it - Troi was a commander, yes, but somewhat ceremoniously as her command status on the ship remained unchained since her role/qualifications were outside of/unsuitable for the main leadership structure. She had a high enough rank to take a shot at that promotion due to her medical qualifications. Since Data, Geordie etc were central to the command structure, my guess is that if they were to achieve promotion it would have to be due to merit that showed they could fill a direct advancement up the tree, rather than no one leaving and that character being promoted to the same rank as a technically, more senior officer, as this may cause awkward respect/discipline issues between those two officers and the crew under them. Since Riker (nor the other characters for that matter) wasn't going anywhere, Data couldn't advance to take his place, and so neither could Geordie etc.
However, from a writer's perspective, my suspicion is that the reason they promoted Troi was that 1) They needed to give her character something to do - an arc of personal growth over the later seasons 2) Moreover, they needed to boost her sense of qualification in the audience's mind - being empathic made her the perfect person on the ship to be the Captain's aid, so that's a reason why she should be on the bridge/by Picard's side, but other than that there was little reason for many people for her to be a senior officer, and have some form of command presence over others, when she wasn't qualified to do so. The real reason she had all that screen time of course was cause she was an important character not officer. This is 'The Wesley Problem' - it annoyed a lot of people that you had a character in the middle of scenarios they ordinarily wouldn't be in, just so stories could be written about them.