Local and Global Casimir Energies: Divergences, Renormalization, and the Coupling to Gravity