Foamy histiocytes form when macrophages ingest a large amount of lipids, either from cellular debris, necrotic cells, or extracellular lipid deposits. These lipids accumulate within the cytoplasm, creating the characteristic foamy appearance. This process can occur in response to various conditions, including infections, metabolic disorders, and chronic inflammation.