Difficulty

Difficulty can be toggled via the options menu in Minecraft. Changing this option has a direct impact in the gameplay itself. There are currently four difficulties in the game: Peaceful, Easy, Normal and Hard

When the difficulty is set to Peaceful, hostile mobs don't spawn naturally. When they spawn from spawners, they are removed from the game instantaneously. Players regain health over time. Despite regaining health over time, it is still possible to die if damage is received quickly enough. Switching from any other difficulty setting to Peaceful results in existing hostile mobs, except for hostile wolves and iron golems, being removed from the world. The Food Bar never depletes and players cannot eat anything except Golden Apples, unless the player has switched to Peaceful when their Food Bar was below the maximum.

Hostile mobs spawn in Easy difficulty. Enemies deal less damage than on Normal difficulty. Creepers will cancel their explosions after moving only a short distance away. The Food Bar can deplete and will leave the player with if it drains completely. Cave Spiders cannot poison players on Easy difficulty, and the Wither won't cause the Wither effect, although Wither Skeletons will.

On Normal difficulty, hostile mobs spawn. Enemies deal standard damage. The Food Bar can deplete and will leave the player with if it drains completely.

On Hard difficulty, hostile mobs also spawn. Enemies deal greater damage than on Normal difficulty. The Food Bar can deplete and will slowly kill the player if it drains completely. Creepers will not cancel their attack unless a large distance is between them and the player, making the explosion much harder to avoid. Zombies break through wooden doors. Spiders can spawn with potion effects.

Regional difficulty
Regional difficulty is the gradual increase of difficulty as players spend time in an area. This effect is capped and difficulty will not continue to grow after a chunk has contained players for more than 50 hours. Note that regional difficulty is a cumulative measure of time—if 50 players spend a single hour in a chunk, it will have maximum regional difficulty.

The effects of regional difficulty are limited to the mobs which naturally spawn in these chunks. If a mob is spawned due to lighting conditions, a spawn egg, or a naturally generated monster spawner, it will be affected by regional difficulty.

Moon phase
The phase of the moon has similar effects on the difficulty of naturally spawned mobs. The fuller the moon is, the higher the chance of naturally spawned mobs having various items and abilities and slimes are more likely to spawn aboveground in swamp biomes. Note that the moon does not actually have to be out for this effect to take place—the effect of the moon's phase exists even at daytime.

Hardcore gamemode
Hardcore causes the player to spawn in Hard difficulty and does not allow it to be changed. In single player, If the player dies, the world is deleted. In Multiplayer, If the player dies they are automatically banned from the server.

Tips
If you are having trouble getting started or exploring caverns, the best thing to do is change the difficulty to "Peaceful". You will be able to explore caves or build a base/HQ much more easily. However, this does not give you the full experience, and you will have to turn the difficulty up if you want to get all the items and tools, such as the bones to make bone meal. In all versions since the 1.8 beta Adventure Update, you may also find cobwebs, that, when destroyed with a sword, give you String. A good recommendation is to turn on Peaceful during the day, and then turn the difficulty back up at night IF you are prepared. This way, you can get the benefits of both ways to play.

Another idea is to change to peaceful whenever you venture into a cave, then turn it back up whenever you leave and go outside or to your house. That way you encounter the enemies above ground at night, but you don't have to worry about a creeper suddenly exploding or a skeleton shooting at you from dark corners when you go into a cave or dying from hunger while mining (many actions performed while mining will make you very hungry, going into a cave without enough food on hard difficulty can easily end in death).

It can be difficult to get your feet wet if you are constantly attacked when first entering The Nether (Particularly since some computers can freeze when switching between the two areas), so changing the difficulty to Peaceful will stop the Ghasts attacking you. Alternatively, standing inside the portal will protect you from being seen by mobs or hit by other players while the lag stops. This also works on servers where altering the difficulty is impossible.

In the Nether, difficulty does not affect hostile mob spawning in any way, with the exception of hostile mobs not spawning at all in Peaceful.

On servers 0 difficulty is Peaceful, 1 is Easy, 2 is Normal, and 3 is Hard. Doing sets it to Easy.

Trivia

 * Notch made a tweet on October 22nd 2010, stating that he's "changing difficulty to realism. Lowest setting = creative. Highest setting = starve". This was never implemented, however "hardcore" mode was added along with a creative gamemode. Creative mode makes the player an invulnerable non-target, peaceful remains unchanged, easy and normal allow damage from hunger but not full starvation, hard allows one to starve to death, and hardcore mode adds permanent death.