To have a united earth like you'd see in Star Trek or whatever, it'd take a hell of a lot of work.
Modelling it after the political system of the USA, there'd still be vast differences between regions. Imagine if any state, take Texas for example, was full of muslims and the state government operated under sharia law. We may have one big government uniting us all overall, but we would not be united in almost every other aspect.
Firstly, every country would need to trust each other. Secondly, to be truly united we'd need equality and tolerance, so intolerant and (if you pardon me saying this) relatively backward places like the Middle East, India, North Korea etc would need a major change. An extreme change, considering by modern standards certain places are more than a millennium behind when it comes to human rights.
We could certainly have a President of Earth, but we will still be bound by geopolitics. There would still be huge differences between Europe and Asia for example.
The USA was built through extreme violence, as was the European Union (through world war 2), and they are the closest examples of a united peoples. It would take something massive (to use the example of a nuclear war in the Star Trek universe) to lead to unity between every culture, religion, etc.
It's a nice idea, and certainly possible, but it seems incredibly hard to do.