@FgoSegul
You're misunderstanding something important. The perspective of the Kingdom is not the perspective of the Goddess. She knows the future and how things will play out. The mortals do not. The MC has a line on future events because of the Goddess riding shotgun and telling him things. The Kingdom has no way of knowing that the King will ever successfully produce another male heir. The Goddess knows that another male child will be born in a few years, but that's because she's a deity. From the Kingdom's perspective, the MC may very well be the only son the King ever successfully has, and if that's the case, then even if they can't allow him to inherit the throne, they could marry him off to some female noble and make his child (the King's grandchild) the heir instead.
The Kingdom is keeping the MC around because they still have very good reasons to. If he's the only male ever produced by the King, then his existence is absolutely necessary no matter how much the King personally despises him or how much their culture insists he's useless. The Goddess is the only one who knows that the MC is going to become obsolete and unnecessary in a few years. Because she can see the future. Nobody else can.