He was actually a pilot before he went to space. Rumor is that he was picked partly because of his diminutive size.
Gherman Titov was the first choice, however Gagarin had the proper “proletarian” peasant background, thus rode Vostok 1. It was about propaganda value.