Why are activities of solids and liquids taken to be unity?
It is not that case that the activity of solids and liquids is always taken as unity.  

Instead, activity is unity for a pure solid or pure liquid at standard pressure.

This is a matter of definition of "activity" and "standard state".

According to the IUPAC definitions: 

activity (relative activity), a


  Defined by the equation
  $a=e^\frac{\mu-\mu ^0}{RT}$
  where $R$ is the gas constant, $T$ the thermodynamic temperature, $\mu$ the chemical potential
  and $\mu ^0$ the standard chemical potential the definition of which depends on the choice of the standard state.


and standard state


  State of a system chosen as standard for reference by convention. Three standard states are recognized: For a gas phase it is the (hypothetical) state of the pure substance in the gaseous phase at the standard pressure p = p °, assuming ideal behaviour. For a pure phase, or a mixture, or a solvent in the liquid or solid state it is the state of the pure substance in the liquid or solid phase at the standard pressure p = p ° ...


So activity is 1 almost by definition when a substance is in its standard state, because $\mu - \mu ^0 = 0$  and $e^0 = 1$