Although Sharia was the king's beloved, she was a lower-ranked noble. The noble faction lobbied the king to marry a higher-ranked noble, which meant he had to take Ellia as queen consort. Ellia schemed for more power, so she got her people to poison Sharia.
It didn't help the king was incredibly overprotective of Sharia and isolated her away to protect her from palace politics, but ended up alienating her further. As a result, Alfred is pretty resentful of palace life and the king.