Pianos these days usually come in two types: acoustic and electrical. Acoustic pianos are basically gigantic boxes filled with tightly strung and closely tuned strings, which are hit by delicate hammers to produce different notes. These hammers are controlled by the keys on the keyboard, each of which is matched to a separate note. A good way to imagine the inside of an acoustic piano visually--if you've never seen one, that is--is to think of a harp that's been laid on its side. The quality of the piano's eventual sound is dependent on many factors, including the quality of the materials used to make it, the delicacy of its mechanism and, if it's been previously used, how old it is. Many old pianos can sound as good, if not better, than new ones, but in order to do so they must have been well-tuned and monitored by their previous user.
Many musicians consider the piano the most versatile of the classical instruments. Unlike your average percussion instrument (drums, for example), it can play melodies; unlike your average melodic instrument (violin), it can play rhythm as well. In fact, most piano pieces allow the musician to play multiple parts at the same time--and if another person is added to the mix (in a duet), the parts multiply accordingly.
The electric piano keyboard tries, first of all, to imitate the sound of an acoustic piano. Whether or not it does this accurately is up for discussion (purists tend to maintain that not even the most developed electronic instrument can possibly match its acoustic equivalent). On the other hand, electronic keyboards can usually synthesize a wide variety of sounds, allowing for a huge amount of musical diversity.