Apples are items that restore health. The red apple restores 2 health while the gold apple restores all of your health. Apples are very rare and only found in dungeons. Very rarely will you find a golden apple in dungeons, typically you have to craft one out of a red apple and 8 gold blocks.
Gold blocks as well as most gold items in the game are considered primarily for vanity because you have to go to great lengths to actually get gold. It is said that Notch added code in the game that when he is playing and he dies he drops a red apple, lol.