Temples encompass Spiritual Science

Bharath is a country known for many beautifully architected temples. What is the science behind these temples? Are they meant to feed priests, as some non-believers state? Is temple a structure for community gatherings that encourages a moral and