Small history lesson for ya'...
Prior to the formation of DHS, you had the INS, the Customs Service, and the Animal and Plant Health Inspection Service of the USDA. All had Inspectors and Special Agents. The former worked at ports of entry, processing people and things entering the country. The latter worked all over the country doing investigations. The INS also had the Border Patrol, which apprehended people entering the US between ports of entry (illegally).
In March of 2003, DHS was formed. The not-so-bright idea was to merge the two agencies into several different agencies. The Inspectors (renamed as Officers) went to CBP. The Border Patrol did as well, but remained semi-autonomous. (A good comparison would be the Marine Corps being a part of the Navy.) The Special Agents (except for USDA) went to ICE, where they were joined by the Federal Protective Service and, for a time, the FAM's. The "service" side of the INS went to a new agency called CIS.
So, the short version:
CBP -- uniformed presence at ports of entry
Border Patrol -- uniformed presence between ports of entry
ICE -- plain clothed investigators nationwide