Being frequently exposed to foreign nucleic acids, bacteria and archaea have developed an ingenious adaptive defense system, called CRISPR-Cas. The system is composed of the Clustered Regularly Interspaced Short Palindromic Repeats (CRISPR) array, together with CRISPR (<i>cas</i>)-associated genes. This system consists of a complex machinery that integrates fragments of foreign nucleic acids from viruses and mobile genetic elements (MGEs), into CRISPR arrays. The inserted segments (spacers) are transcribed and then used by cas proteins as guide RNAs for recognition and inactivation of the targets. Different types and families of CRISPR-Cas systems consist of distinct adaptation and effector modules with evolutionary trajectories, partially independent. The origin of the effector modules and the mechanism of spacer integration/deletion is far less clear. A review of the most recent data regarding the structure, ecology, and evolution of CRISPR-Cas systems and their role in the modulation of accessory genomes in prokaryotes is proposed in this article. The CRISPR-Cas system's impact on the physiology and ecology of prokaryotes, modulation of horizontal gene transfer events, is also discussed here. This system gained popularity after it was proposed as a tool for plant and animal embryo editing, in cancer therapy, as antimicrobial against pathogenic bacteria, and even for combating the novel coronavirus – SARS-CoV-2; thus, the newest and promising applications are reviewed as well.