'Wish you were here' has long been expressed in letters home by people on holiday. It is most often associated with postcards though. Postcards in the sense we now know them are picture postcards, i.e. a picture, usually a scene from the locality of one's holiday, on one side and a pre-printed layout, with spaces for a message and an address, on the other. These were introduced at the end of the 19th century. Prior to that there were cards, properly called postal cards, that were pre-stamped and printed with advertising or patriotic slogans and pictures.
In 1898 the American government allowed private postcards to be sent with one cent stamps. This was cheaper than the prevailing letter rate and began the widespread use of postcards by the public.
The 'wish you were here' sentiment soon became a cliché and appeared on a high percentage of cards, often preceded by 'having a lovely time'. So much so that cards became available with the text pre-printed.