Despite popular misconception or assumption, pre-1868 Japan was exceptionally accepting, even encouraging, of same-sex relationships between men and bisexuality, especially within the confines of the Samurai warrior classes. This is in part due to the consensus between the religious and military institutions on the matter, the two most powerful factions in shogunate controlled Japan.
Buddhism and its values were respected by the Samurai, so generally, sons of the samurai class would receive their education from the monks at Buddhist monasteries. Because the Buddhist religion took a rather nonchalant approach to same-sex relationships between men, the ideals of the religion being learned by the samurai class also allowed for the premise of the male bond to become intrinsically linked with a romantic and often sexual relationship. These kinds of relationships became usualised or even optimal for multiple generations of samurai.
It has also been hypothesised by some Japanese historians that the man to woman ratio in cities had a part to play in the commonality of same-sex relationships between men. Because the leading power during the shogunate were the military, the cities of Japan were mostly populated by male warriors and samurai, causing a roughly 20-80 woman to man ratio in the city’s populaces. It was easier to fulfill one’s sexual needs with another man than finding a woman to engage in a romantic relationship with.
A debate spanning almost a century in multiple pieces of Japanese literature was that of which was better, heterosexual or homosexual relationships.
Denbu Monogatari, ‘The Boor's Tale’, 1640: “men are bathing in a river to escape the heat. They begin to debate whether the love of a boy or a woman is better. In the end, the woman-loving side wins, but not before conceding that male-male erotic pursuits are well suited to the higher circles of the warrior aristocracy.”
Iro Monogatari, ‘Tale of Eros’, mid-seventeenth century: "an elderly arbiter, after hearing the impassioned arguments of the two sides, counsels that the wisest course is to follow both paths in moderation, thereby helping to prevent overindulgence in either."
Nishizawa Ippuu, ‘Yakei Monoamines’, 1708: "a moderator ends the dispute by affirming the equal validity of both ways, encouraging each party merely to be devout in his chosen discipline."
Ultimately through the debate, it becomes clear that there was a studied consensus about how the pre-modern Japanese felt about same-sex relationships.