For the purpose set forth in Sections 10002 and 10003 a municipal corporation may acquire, own, control, sell, or exchange lands, easements, licenses, and rights of every nature within or without its corporate limits, and may operate a public utility within or without the corporate limits when necessary to supply the municipality, or its inhabitants or any portion thereof, with the service desired.