A common explanation, the one accepted by Oxford Dictionaries,
is that it comes from Royal Air Force slang. However, nobody
there or anywhere else seems to know why. Some say that it
may have been applied to the efforts of pilots to do aerobatics,
such as loops. It is notoriously difficult (I am told) to get
manoeuvres like this even roughly circular, and instructors would
describe the resulting distorted route of the aircraft as
pear-shaped.
I’ve not seen firm evidence to convince me of this explanation,
which sounds a little far-fetched, but that’s the best I can do