Religion was a big part of Japan and for samurai. Japan's original religion was shinto, which expressed love and respect or the Japanese for nature. Then a religion called Buddhism came to Japan. Buddhism originated in India and influenced China, Korea, then Japan. This religion was brought to Japan from Prince Shotoku. Buddhists usually think life as suffering or pain. It structured society because everyone had to have a religion to believe in and have peacefulness. Society would be different without religion because they would have to develop a new thing to believe in. If they didn't have a religion everything would fall and not have structure.
The samurai code had to do with Bushido, "The way of the warrior." This governed a samurai's life. They were to have loyalty and personal honor more than their lives. Samurai also were expected to guard their honor. It helped structured society because it taught a samurai to be honest, fair, and fearless of death. Without it warriors and samurai would lose their faith.
Sense of Honor
Samurai had a sense of honor. This had a part in Bushido too, and also taught themselves to be mental trained. It taught them to be fearless of death and full of respect and honor. When failing the Bushido code they must do a ritual suicide also known as seppuka. Some samurai killed themselves when their lord died or as form of protest against an injustice. This structured society because it taught samurai to have self discipline and had honor after battles. It would be different without it because they would not have respect and peacefulness.