I am looking for mainly a kdrama or cdrama with historical setting in which the ML is the King or prince.

I want the ML to be smart  and good at politics.

I would love romance with it but not a necessity let me know how much romance the drama has and try to avoid sad endings.

I think Good Bye My Princess really fits your description. ML is prince who is smart in politics and wants to get revenge. There is also romance but what's important is the impact of love between leads not romantic or sweet scenes. What I mean is that you will not see a lot of light and cute scenes like in rom com kdramas. I'm currently watching Good Bye My Princess and I love it! There is only one problem that it's a tragedy. I haven't seen the ending yet but I think it will be heartbreaking.

Rise of Phoenixes (not romance focused, but there's a lot of it) spoiler: sad ending

Nirvana in Fire (not romance focused, but it is present)- it doesn't exactly meet your criteria, but we have a smart strategist who helps the prince. And it's effing awesome 

You might be interested in Legend of Hao Lan.   The 2nd ML (a prince that turns into the king) really competes for what would be considered the ML in this drama.    He is a slow burn ML.  Midway thru the show i found myself thinking....wait, who IS the ML?     He is why I (and many) watched the show.   And for the reasons u mentioned.   Smart at politics and relationships.   There is a romance thread or two...well a triangle but not the complete driver for the story.*

*Based on true story.      

Maybe Haechi. It has a bit of romance, an happy ending and the main character is a prince who is striving to become king. Personally I really loved this series, hope it will be what you are looking for!

Depending on your definition of politics: Shine or Go Crazy. He's not an adept politician but he's good at uncovering things and playing certain situations the correct way.

Six Flying Dragons and Tree with Deep Roots both feature politically brilliant kings/princes, but they don't have happy endings.  Jumong has a prince who starts out as a mess, but grows into a highly successful leader - the ending is bittersweet, but generally positive.

hmm, I think the eternal love may fit that