What factors contributed to Muhammad's decision to establish the first Islamic state in Medina?