I would like to know how an IC works in theory. What do the pins do? How do they relate with each other? Is one side always positive and the other negative? How do I know?, etc.
There are a lot of different IC's.
The theory behind each IC will be different.
There are analog IC's (opamps, comparators etc.),
Digital IC's (single ports, flip-flops, counters and microconthollers, memory etc.).
There are even combined IC's for special purposes.
They are not all alike. Each one has an associated data sheet, freely available on the internet. Most have a partial schematic of the internal features. Some analog IC's, like op amps, follow the old LM741 pinout, and so are somewhat interchangeable, but have different operating characteristics.
Logic families, so called, do share common features like operating voltage and such, but analog IC's can be very different from one another.
As example, get data sheets for a SN7400, a CD4000, an LM555, and an OPA134 - that's two digital and two analog IC's (although the 555 is a kind of hybrid).