Difference between the terms 'famous' & 'infamous'; 'valuable' & 'invaluable'

The prefix does its job faithfully regardless of the ultimate result of connotation or implication. Some explanation may be in order.

in-: prefix denoting 'not'.

in + famous → not famous
&
in + valuable → not valuable (Patience!)

fame: good reputation; famous: widely known for something good;
infamy bad reputation; infamous: widely known for something bad. – Naturally?

value (n): worth;
(to) value (v): to estimate the worth of;
valuable: that whose worth can be estimated;
invaluable: that whose worth can not be estimated; too valuable.

It all adds up nicely.

The prefix modifies in a mechanical way here, while the meaning on the other hand, depends on the nature of the word, its original implication, even its etymology and usage. Even not valuable can be understood in the right context to mean something that cannot be valued (not value+able).