Fighting in Minecraft is a largely simple affair and you have two main weapons with which to fight, a sword and a bow.
What you have here is a close and ranged option. Most enemies will suffer willingly to your sword should you get close but as you progress through the game the chances are you’ll start to lean more heavily on the bow until you get a very strong set of armor to soak up the hits.
To use the sword effectively you want to get close to an enemy, swing, and then step back. You’re trying to fight at tip’s length rather than right up in your enemy’s face. While you can block it’s better to keep them at a distance if possible, it’s more reliable. A good bit of advise is to use any bottleneck you should find - or create for that matter - as the enemies of Minecraft are easily funneled into death zones and sides, you want to avoid getting surrounded.
Some enemies, however, you’ll always want to try and dispatch with the Bow. Take the Creeper for example.
The Creeper is an enemy that will self destruct if it gets too close to you due to its fiendish proximity detonation. It is possible to get close, trigger him, and escape the blast radius or, indeed, nick it with the tip of your blade to slowly kill it, but both techniques are far from recommended and prone to accident. These enemies are precisely the reason you’ll want a stock of arrows at all times as a few sharp sticks to the noggin will see a Creeper drop without detonating. Later enemies also present issues for the sword wielder, with Ghasts often hovering over pools of lava, requiring ranged tactics to fell. When dealing with enemies at range be wary of the Bow’s sharp drop, you’ll want to aim just above an enemy at long range to hit them.
Just make sure you’re stocked up, suited up, and fight carefully. Oh and Remember: running away when you have pockets of loot isn’t cowardice, and it’s always preferable to losing it through over confidence or a stealthy Creeper to the back.