it's a rite of passage. It says to family, friends and the community at large that you're embarking on a new stage of your life, starting a new family and leaving your old one. In days gone by, I would imagine just living to this age would be quite an achievement and well worth celebrating. Actually, aside from christenings and funerals it's the only rite of passage left - divorce parties never really caught on and only Jews still have puberty ceremonies, I think. (I once got invited to a circumcision* party in Turkey, so maybe that's a rite in Islam, I don't know.)
Historically, I don't think it had anything to do with religion; but in the middle ages the church tried to take them over, to help it impose its standards of sexual morality on society. The idea of marriage being a religious ceremony rather than a civil one lasted centuries, but seems to be in retreat again now.
*male