There is no precise date for when the piano was invented. And even the earliest versions of what we may recognize as one did not have all of the same parts we find on contemporary upright and grand pianos today.
The first instrument to possess these properties was the clavichord, built in the late Middle Ages (circa 13th century), whose tones were created by small metal plates hitting the strings. However, this type of tone generation didn't continue because the volume of the clavichord was too low.
Some consider the harpsichord an even earlier precursor of modern upright and grand pianos even though its strings are plucked and not struck, meaning it doesn't meet our requirements listed above. Nevertheless, the harpsichord and the spinet - a further variant of a keyboard instrument (its strings ran parallel to the keyboard) were the concert and house music instruments of the Baroque period.
However dynamic sounds were difficult to produce as there was really no way to play louder or softer unless you changed the register. It was with the groundbreaking invention of hammer mechanics by the harpsichord maker Bartolomeo Cristofori in 1709 that things truly progressed towards what we have today.
1772 Englishmen Backers and Stodart develope their "English mechanics", which, with their sturdier construction and stronger strings, allowed for very dynamic play and which form the basis of modern grand piano mechanics.
1774 John Joseph Merlin invents the Una corda or shift pedal, which only allows the hammers to hit a single string at a time, allowing for much quieter play (see Focus Pedals)
1821 The Frenchman Sebastian Erard invents repetitive mechanics, which keeps a string from returning to 'rest' between strikes. Something which to this day is only present in grand pianos.
1870 The physicists Helmholtz and Theodor Steinway work closely together and as a result, Steinway discovers a new alloy for the iron plates, which allows for a threefold increase in the tensile strength of the strings and considerably less self-oscillation.
1874 The first grand piano with three pedals is produced by Steinway. The middle pedal allows sounds to continue (sustain), but only those that have already been struck. (see focus pedals)
1887 Japanese watchmaker Torakusu Yamaha builds his first instrument. Thirteen years later he begins producing pianos. One hundred years after that Yamaha becomes the largest producer of pianos and grand pianos, with a weekly production equivalent to Steinway's annual production!
However, pianos, grand pianos and their players were not always well-liked, in 1900 the music critic Eduard Hanslick writes on this topic:
Deep into some important work or serious reading, in need of rest, or struggling for spiritual gathering, we must, unwillingly, listen to the dreadful piano-playing beside us; with a kind of tense fear of death, we wait for the well-known accord, which the dear Fraulein always plays wrongly; we tremble before the course in which the little boy will unfailingly falter and start all over again (...)