The anime you're likely thinking of is "The World is Still Beautiful" (Sekai wa Utsukushii). In this anime, the story revolves around a world where everyone is born female, except for the male king of a small country who is tasked with marrying a princess from a neighboring country.
This anime explores themes of gender roles, societal expectations, and the importance of finding your own path in life. While it presents a unique premise, it also touches on more universal themes that resonate with audiences.