What is XP and what is it good for?

Solution 1:

XP was added in Heart of the Swarm. I'm not sure if it changed for Legacy of the Void since I don't do Starcraft 2 multiplayer, but back during Heart of the Swarm, XP increased your level with that race. Every time you level up, you gain a cosmetic improvement, like a unit skin, a new portrait, a new decal for your buildings,...

The unlocks are all purely cosmetic and do not add power.

Update: in Legacy of the Void, there is also an Co-op mode where you and another player fight together against the AI. This mode has a separate leveling system, where each commander earns XP separately and you unlock new units to build, technology to research or special abilities to use. This leveling system is separate from that of the normal multiplayer.