1.5.4: Sheriam: Black or Blue? --Revised
"During the exile in Salidar, Egwene had worked closely with Sheriam and had grown to like the woman. But she was Black. Egwene's own Keeper was Black." [TGS 59: A Visit from Verin Sedai]
According to Verin's notes on the Black Ajah, Sheriam is a card carrying member of the Black Ajah. It seems likely the Blacks, or perhaps Mesaana manipulated the situation so that she would become Egwene's Keeper and keep an eye on her, and if necessary, foment discord much like Alviarhin did as Elaida's Keeper.
It seems clear from Sheriam's own thoughts that Aran'gar, in her guise as Halima was the one responsible for punishing Sheriam in the earlier books. "...Romanda had been the one to chase Halima-- and Sheriam's punishments-- out of the camp." The cause of the torture seems to be Aran'gar's desire for information about Egwene's plans, since Egwene won't confide in her masseus herself.