The bachelor is given alcohol and subjected to temptation by his peers as a test of his mettle. It is literally a test of the bachelor's resolve. A trial-by-fire. To pass through it clean is to prove that the groom is of pure heart and that his love for his bride is true. It's a symbolic turning point where a man passes from hapless bachelor to worthy groom as a good man. There is nothing more important to a man's self image than being perceived as a good, worthy man. There is no way for a man to prove his worth without first being tested. Therefore, for many men, the bachelor party is an important transition in manhood.
Believe it or not, the bachelor party is also a test of the bride's mettle. This is the groomsmen's last opportunity to vet the bride as a well-adjusted woman who won't subject their beloved compatriot to fits of jealousy. Will she be a trusting, loyal companion or a controlling shrew? This is their way of testing her trust in their friend and ensuring she is a good mate.
Additionally, this is an important ceremony for the groom-to-be's friends. It is a viking funereal of sorts where they can say goodbye to the bachelor—the wingman—they once knew, and greet with open arms at the end of the night the husband the man will become. Weddings are important to women. Bachelor parties are just as important to men, because in the minds of the men who attend, the bachelor is a groom at the end of the night, and the wedding itself is just a formality with uncomfortable clothing and (hopefully) an open bar. For men, it's like the bachelor party is election night and the wedding is the inauguration.