Given the meaning of the phrase ranging from benign "Go away" to the rude "Пошел на ..."
I am curious of the origins of this form?
In Russian mythology "баня" is the place of evil spirits.
The third firing (or fourth, depending on tradition) was reserved for the Bannik, and, given his inclination to invite demons and forest spirits to share his bath, no Christian images were allowed lest they offend the occupants.
Thus, the meaning of пошел в баню
is very close to пошел к черту
.
My amateurish 3 cents. I think it started with the saying "Пошел к черту" meaning to curse somebody. In this regard "пошел" makes perfect sense, how else would you get to the devil?
UPDATE: about the roots of "баня" as a place to go
I like the explanation that I found here in Russian and confirmed later here and here in French:
Средний возраст посетителей публичных домов составлял около двадцати семи лет. Женатым мужчинам теоретически запрещалось наведываться в бордель, однако на деле это правило никогда не соблюдалось, невзирая на периодически устраивавшиеся в заведениях облавы. Начать с того, что правило это не распространялось на чужестранцев; кроме того, за некоторую дополнительную плату мужья вполне могли рассчитывать на благосклонность хозяев борделя.
Зато им совершенно не возбранялось посещать бани, которые, несмотря на многочисленные запреты, неизменно служили для тех же целей, что и бордели. Таких бань в каждом большом городе существовало по нескольку (в Лионе и Дижоие в 1470 году было по семь таких заведений). Владельцами бань были весьма высокопоставленные лица, в том числе и духовного звания. Не случайно в Лионе выражение "aller s'estuver" (идти в баню) имело в XV веке вполне определенный смысл. В банях было множество потаенных убежищ и запасных выходов на случай обыска. При этом около 20% клиентуры составляло духовенство.
UPDATE2:
Although the explanation above looks pretty reasonable, Mr. Google N-Gram says it's not the case with Russian. The mention of the phrase "иди в баню" surged in 40's of the last century which makes me guess about other versions.
"Пошел в баню" doesn't really have to do anything with баня itself, it's just a soft form of "пошел к черту" and some much stronger swear-like expressions starting with "пошел в/пошел на". There are some other (soft) expressions that are being used with the same purpose, such as "шел бы ты лесом". Again, "лес" here is irrelevant to the meaning.
We can theorize all we want, and mention that a баня is a place where you wash yourself, so it may be a hint that the person is dirty or that he stinks, and that баня is usually located outside the home, so it's a nice way of sending the person away, or that it's very hot so maybe it's a colloquial euphemism for hell - but at the end of the day it's just an expression taken from the everyday country life and involving everyday household objects. I wouldn't read much into the specific use of the term. It's like asking why they say "as dumb as a bag of hammers". Why is a bag of hammers dumber than a bucket of gravel, for instance? :) It's just an expression, I don't think it's quaint enough to have any special meaning.