What is the etymology of the phrase "one trick pony"?
A pony that only knows one trick.
Can ponies do tricks?
Yes. Especially in circuses.
Indeed the OED gives for the literal definition "esp. one performing in a circus" which strikes me as amusing; let's make sure a pedant who finds a one-trick pony outside of a circus doesn't prove us wrong!
Anyway, their first quotation is:
Among the earliest of mundane things remembered are the resplendent red shirts of the volunteer firemen, conspicuous in every Fourth of July parade; the marvels that were seen at the first one-tent, one-clown, one-trick-pony, pioneer Oregon circus.
This from the Oregon Pioneer Association 32nd Ann. Reunion published in 1905. While there may be a degree of figurative use (it would be pedantry to correct them if you found out that this circus had in fact had two clowns, and didn't actually have a pony at all), it is still using "one-trick-pony" to refer to a small horse that has been taught a single trick.
Now, kids today with their games-consoles and their boy-bands and their player-pianos might not be particularly impressed by circus ponies (though circuses do still have ponies and horses that do tricks), and so we don't really have much call to cast aspersions on actual circus ponies that lack versatility, and so the figurative use is now much more common than the literal, but the literal sense is the origin of the figurative, and it really is as simple as being a pony that knows one, but only one, trick.