Origins and Diversification of a Complex Signal Transduction System in Prokaryotes