Most actions you perform in the game will give you XP. Doing events, killing enemies, even mining blocks can give XP. So you will naturally work towards this as you play.
When you kill an enemy it will drop yellow loot. This is your XP for the kill so make sure you are looting them.
I personally reached level 10 at 6 hours of play, but I spent a lot of time building up a home on the first level rather than progressing through, so I am sure it could be earned a lot quicker